From 79bfcc4f7ae4bcd61f7f942bfefb940c77927b71 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Mon, 27 Aug 2018 18:36:13 -0400 Subject: Add configuration key, handle whereever NULLABLE is handled, support Eclipse. --- src/utils/lombok/eclipse/Eclipse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/utils') diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 5dbe3e2d..42adeeac 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -155,6 +155,24 @@ public class Eclipse { return result.toArray(EMPTY_ANNOTATIONS_ARRAY); } + /** + * Searches the given field node for annotations and returns each one that matches the provided list of names. + */ + public static Annotation[] findExactAnnotations(FieldDeclaration field, List names) { + List result = new ArrayList(); + if (field.annotations == null) return EMPTY_ANNOTATIONS_ARRAY; + for (Annotation annotation : field.annotations) { + TypeReference typeRef = annotation.type; + if (typeRef != null && typeRef.getTypeName() != null) { + String annoname = toQualifiedName(typeRef.getTypeName()); + if (names.contains(annoname)) { + result.add(annotation); + } + } + } + return result.toArray(EMPTY_ANNOTATIONS_ARRAY); + } + /** Matches any of the 8 primitive names, such as {@code boolean}. */ private static final Pattern PRIMITIVE_TYPE_NAME_PATTERN = Pattern.compile( "^(boolean|byte|short|int|long|float|double|char)$"); -- cgit