aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/handlers/HandleSetter.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-08-28 00:02:15 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-08-28 00:02:15 +0200
commite1ee1b7d2db1ea998aa4d6aa3f6b4141315a9496 (patch)
tree5f014017561f6a9cff56e8ad35f2c6e3cf7b882e /src/lombok/javac/handlers/HandleSetter.java
parentd16775032b638789f998f3f362b7ed7d4f5098ae (diff)
downloadlombok-e1ee1b7d2db1ea998aa4d6aa3f6b4141315a9496.tar.gz
lombok-e1ee1b7d2db1ea998aa4d6aa3f6b4141315a9496.tar.bz2
lombok-e1ee1b7d2db1ea998aa4d6aa3f6b4141315a9496.zip
null checks are no longer generated if you put @NonNull on primitives.
Diffstat (limited to 'src/lombok/javac/handlers/HandleSetter.java')
-rw-r--r--src/lombok/javac/handlers/HandleSetter.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lombok/javac/handlers/HandleSetter.java b/src/lombok/javac/handlers/HandleSetter.java
index 412b1c43..253b0325 100644
--- a/src/lombok/javac/handlers/HandleSetter.java
+++ b/src/lombok/javac/handlers/HandleSetter.java
@@ -25,6 +25,7 @@ import static lombok.javac.handlers.PKG.*;
import lombok.AccessLevel;
import lombok.Setter;
import lombok.core.AnnotationValues;
+import lombok.core.TransformationsUtil;
import lombok.core.AST.Kind;
import lombok.javac.Javac;
import lombok.javac.JavacAST;
@@ -120,13 +121,15 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
JCAssign assign = treeMaker.Assign(thisX, treeMaker.Ident(fieldDecl.name));
List<JCStatement> statements;
- List<JCAnnotation> nonNulls = findAnnotations(field, NON_NULL_PATTERN);
- List<JCAnnotation> nullables = findAnnotations(field, NULLABLE_PATTERN);
+ List<JCAnnotation> nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN);
+ List<JCAnnotation> nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN);
+
if (nonNulls.isEmpty()) {
statements = List.<JCStatement>of(treeMaker.Exec(assign));
- }
- else {
- statements = List.<JCStatement>of(generateNullCheck(treeMaker, field), treeMaker.Exec(assign));
+ } else {
+ JCStatement nullCheck = generateNullCheck(treeMaker, field);
+ if (nullCheck != null) statements = List.<JCStatement>of(nullCheck, treeMaker.Exec(assign));
+ else statements = List.<JCStatement>of(treeMaker.Exec(assign));
}
JCBlock methodBody = treeMaker.Block(0, statements);