aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/JavacHandlerUtil.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2020-04-17 01:37:08 +0200
committerGitHub <noreply@github.com>2020-04-17 01:37:08 +0200
commit20cce2049de56d5a71c6dcc376d6f4088d4552bc (patch)
treec2eeec699f50e15b07c329d9e6b969369c9e12b8 /src/core/lombok/javac/handlers/JavacHandlerUtil.java
parent9d50e9f8ad16c463b6ff9dbb87fd7a012c68bfef (diff)
parentdede79bc224eb16566a027f83214c04e065b575b (diff)
downloadlombok-20cce2049de56d5a71c6dcc376d6f4088d4552bc.tar.gz
lombok-20cce2049de56d5a71c6dcc376d6f4088d4552bc.tar.bz2
lombok-20cce2049de56d5a71c6dcc376d6f4088d4552bc.zip
Merge pull request #2429 from janrieke/jacksonAndSingularAnnotationCopy
Copy more Jackson annotation to the builder, also to @Singular methods
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index a3e876c4..5241a209 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1520,6 +1520,20 @@ public class JavacHandlerUtil {
* Searches the given field node for annotations that are specifically intentioned to be copied to the setter.
*/
public static List<JCAnnotation> findCopyableToSetterAnnotations(JavacNode node) {
+ return findAnnotationsInList(node, COPY_TO_SETTER_ANNOTATIONS);
+ }
+
+ /**
+ * Searches the given field node for annotations that are specifically intentioned to be copied to the builder's singular method.
+ */
+ public static List<JCAnnotation> findCopyableToBuilderSingularSetterAnnotations(JavacNode node) {
+ return findAnnotationsInList(node, COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS);
+ }
+
+ /**
+ * Searches the given field node for annotations that are in the given list, and returns those.
+ */
+ private static List<JCAnnotation> findAnnotationsInList(JavacNode node, java.util.List<String> annotationsToFind) {
JCAnnotation anno = null;
String annoName = null;
for (JavacNode child : node.down()) {
@@ -1537,7 +1551,7 @@ public class JavacHandlerUtil {
if (annoName == null) return List.nil();
if (!annoName.isEmpty()) {
- for (String bn : COPY_TO_SETTER_ANNOTATIONS) if (typeMatches(bn, node, anno.annotationType)) return List.of(anno);
+ for (String bn : annotationsToFind) if (typeMatches(bn, node, anno.annotationType)) return List.of(anno);
}
ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>();
@@ -1545,7 +1559,7 @@ public class JavacHandlerUtil {
if (child.getKind() == Kind.ANNOTATION) {
JCAnnotation annotation = (JCAnnotation) child.get();
boolean match = false;
- if (!match) for (String bn : COPY_TO_SETTER_ANNOTATIONS) if (typeMatches(bn, node, annotation.annotationType)) {
+ if (!match) for (String bn : annotationsToFind) if (typeMatches(bn, node, annotation.annotationType)) {
result.append(annotation);
break;
}