@Override public boolean replaceChild(Element child, Element by) { if (child == getAnnotationClass()) { setAnnotationClass((TypeRef)by); return true; } if (child == getDefaultArgument()) { setDefaultArgument((Expression) by); return true; } return replaceChild(namedArguments, Expression.class, this, child, by) || super.replaceChild(child, by); }
public void visitAnnotation(Annotation annotation) { visitElement(annotation); visit(annotation.getAnnotationClass()); visit(annotation.getDefaultArgument()); visit(annotation.getNamedArguments()); }
public void visitAnnotation(Annotation e) { append("@", e.getAnnotationClass()); boolean first = true; boolean hasDefault = e.getDefaultArgument() != null; boolean hasNamed = !e.getNamedArguments().isEmpty(); if (hasDefault || hasNamed) { append("("); if (hasDefault) { if (hasNamed) append("value = "); append(e.getDefaultArgument()); first = false; } for (Map.Entry<String, Expression> entry : e.getNamedArguments().entrySet()) { if (!first) append(", "); append(entry.getKey(), " = ", entry.getValue()); first = false; } append(")"); } space(); }