in dataenum-processor/src/main/java/com/spotify/dataenum/processor/parser/ValueParser.java [95:124]
private static Iterable<AnnotationSpec> parseMethodAnnotations(
ExecutableElement methodElement, Messager messager) {
ArrayList<AnnotationSpec> annotations = new ArrayList<>();
for (AnnotationMirror annotationMirror : methodElement.getAnnotationMirrors()) {
TypeName annotationTypeName =
ClassName.get(annotationMirror.getAnnotationType().asElement().asType());
if (!(annotationTypeName instanceof ClassName)) {
messager.printMessage(
Kind.ERROR,
"Annotation is not a class; this shouldn't happen",
methodElement,
annotationMirror);
continue;
}
Builder builder = AnnotationSpec.builder(((ClassName) annotationTypeName));
for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
annotationMirror.getElementValues().entrySet()) {
builder.addMember(entry.getKey().getSimpleName().toString(), entry.getValue().toString());
}
annotations.add(builder.build());
}
return annotations;
}