Nguyen Viet Hoa
unread,Feb 20, 2015, 9:41:33 AM2/20/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to xtend...@googlegroups.com
Hi,
I'm not sure it's a bug or my code was wrong. Somebody can help answer this question pls. I've tried to copy fields from one class to another like this:
clazz.declaredFields.forEach [ sourceField |
extensionClass.addField(sourceField.simpleName) [ targetField |
targetField.final = sourceField.final
targetField.static = sourceField.static
targetField.transient = sourceField.transient
targetField.volatile = sourceField.volatile
targetField.initializer = sourceField.initializer
targetField.type = sourceField.type
targetField.docComment = sourceField.docComment
targetField.visibility = sourceField.visibility
sourceField.annotations.forEach[annotationTypeDeclaration|
targetField.addAnnotation(annotationTypeDeclaration)]
]
]
but the code generated is not correct, for example, for the source field : private final HashMap<ArrayList<?>, Model> _createCache_transform = CollectionLiterals.newHashMap();
will give : private final Object _createCache_transform = CollectionLiterals.newHashMap();
and the import expression for the HashMap, ArrayList and CollectionLiterals do not generated automatically for the target class.
Thanks,
Hoa