use of com.github.javaparser.ast.expr.NormalAnnotationExpr in project checker-framework by typetools.
the class AnnotationMirrorToAnnotationExprConversion method annotationMirrorToAnnotationExpr.
/**
* Converts an AnnotationMirror into a JavaParser {@code AnnotationExpr}.
*
* @param annotation the annotation to convert
* @return a JavaParser {@code AnnotationExpr} representing the same annotation with the same
* element values. The converted annotation will contain the annotation's fully qualified
* name.
*/
public static AnnotationExpr annotationMirrorToAnnotationExpr(AnnotationMirror annotation) {
Map<? extends ExecutableElement, ? extends AnnotationValue> values = annotation.getElementValues();
Name name = createQualifiedName(AnnotationUtils.annotationName(annotation));
if (values.isEmpty()) {
return new MarkerAnnotationExpr(name);
}
NodeList<MemberValuePair> convertedValues = convertAnnotationValues(values);
if (convertedValues.size() == 1 && convertedValues.get(0).getName().asString().equals("value")) {
return new SingleMemberAnnotationExpr(name, convertedValues.get(0).getValue());
}
return new NormalAnnotationExpr(name, convertedValues);
}
use of com.github.javaparser.ast.expr.NormalAnnotationExpr in project drools by kiegroup.
the class GeneratedClassDeclaration method addAnnotationToMethodDeclaration.
private void addAnnotationToMethodDeclaration(MethodDeclaration setter, AnnotationDefinition a) {
NormalAnnotationExpr annotation = new NormalAnnotationExpr();
annotation.setName(a.getName());
a.getValueMap().forEach(annotation::addPair);
setter.addAnnotation(annotation);
}
Aggregations