Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.xml.bind.annotation.XmlElement
- @GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION)
- class WebserviceAnnotationModifier implements ASTTransformation {
- @Override
- void visit(ASTNode[] astNodes, SourceUnit sourceUnit) {
- if (!astNodes) return
- if (!astNodes[0] || !astNodes[1]) return
- if (!(astNodes[0] instanceof AnnotationNode)) return
- if (!(astNodes[1] instanceof ClassNode)) return
- ClassNode node = (ClassNode)astNodes[1]
- List fields = node.getFields()
- fields.each {FieldNode field ->
- field.addAnnotation(ClassHelper.make(new XmlElement.DEFAULT()));
- }
- }
- }
- @Retention(RetentionPolicy.SOURCE)
- @Target([ElementType.TYPE])
- @GroovyASTTransformationClass(classes =[WebserviceAnnotationModifier])
- public @interface WebresourceAnnotation{}
- @WebresourceAnnotation
- class TestPerson{
- String name;
- String lastName;
- int Age
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement