super(adapters);
}
@Override
public Annotation adapt(AnnotationContext context) {
Annotation annotation = createNode(context);
AnnotationNameContext annotationNameContext = getChild(context, AnnotationNameContext.class);
if (annotationNameContext != null) {
QualifiedNameContext qualifiedNameContext =
getChild(annotationNameContext, QualifiedNameContext.class);
if (qualifiedNameContext != null) {
annotation.setName(getAdapter(QualifiedNameAdapter.class).adapt(qualifiedNameContext));
}
}
ElementValuePairsContext elementValuePairsContext =
getChild(context, ElementValuePairsContext.class);
if (elementValuePairsContext != null) {
List<NameValuePair> elementValuePairs =
transform(elementValuePairsContext, ElementValuePairContext.class,
new Function<ElementValuePairContext, NameValuePair>() {
@Override
public NameValuePair apply(ElementValuePairContext context) {
return getAdapter(ElementValuePairAdapter.class).adapt(context);
}
});
annotation.setValues(elementValuePairs);
}
ElementValueContext elementValueContext = getChild(context, ElementValueContext.class);
if (elementValueContext != null) {
AnnotationValue elementValue =
getAdapter(ElementValueAdapter.class).adapt(elementValueContext);
annotation.setValue(elementValue);
}
return annotation;
}