* @param enhancedFor an array of feature names to include in the enhancedFor attribute of the annotation
* @return the AnnotationNode associated with the Enhanced annotation for classNode
* @see Enhanced
*/
public static AnnotationNode addEnhancedAnnotation(final ClassNode classNode, final String... enhancedFor) {
final AnnotationNode enhancedAnnotationNode;
final List<AnnotationNode> annotations = classNode.getAnnotations(ENHANCED_CLASS_NODE);
if (annotations.isEmpty()) {
enhancedAnnotationNode = new AnnotationNode(ENHANCED_CLASS_NODE);
enhancedAnnotationNode.setMember("version", new ConstantExpression(GrailsUtil.getGrailsVersion()));
classNode.addAnnotation(enhancedAnnotationNode);
} else {
enhancedAnnotationNode = annotations.get(0);
}
if(enhancedFor != null && enhancedFor.length > 0) {
ListExpression enhancedForArray = (ListExpression) enhancedAnnotationNode.getMember("enhancedFor");
if(enhancedForArray == null) {
enhancedForArray = new ListExpression();
enhancedAnnotationNode.setMember("enhancedFor", enhancedForArray);
}
final List<Expression> featureNameExpressions = enhancedForArray.getExpressions();
for(final String feature : enhancedFor) {
boolean exists = false;
for(Expression expression : featureNameExpressions) {