aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/handlers/HandleSetter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/javac/handlers/HandleSetter.java')
-rw-r--r--src/lombok/javac/handlers/HandleSetter.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lombok/javac/handlers/HandleSetter.java b/src/lombok/javac/handlers/HandleSetter.java
index 2f41e716..9fb995e4 100644
--- a/src/lombok/javac/handlers/HandleSetter.java
+++ b/src/lombok/javac/handlers/HandleSetter.java
@@ -21,7 +21,12 @@
*/
package lombok.javac.handlers;
-import static lombok.javac.handlers.PKG.*;
+import static lombok.javac.handlers.PKG.findNonNullAnnotations;
+import static lombok.javac.handlers.PKG.generateNullCheck;
+import static lombok.javac.handlers.PKG.injectMethod;
+import static lombok.javac.handlers.PKG.methodExists;
+import static lombok.javac.handlers.PKG.toJavacModifier;
+import static lombok.javac.handlers.PKG.toSetterName;
import lombok.AccessLevel;
import lombok.Setter;
import lombok.core.AnnotationValues;
@@ -34,8 +39,6 @@ import lombok.javac.JavacAST.Node;
import org.mangosdk.spi.ProviderFor;
import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.code.TypeTags;
-import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCAssign;
@@ -127,11 +130,7 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
statements = List.<JCStatement>of(treeMaker.Exec(assign));
}
else {
- JCExpression npe = chainDots(treeMaker, field, "java", "lang", "NullPointerException");
- JCTree exception = treeMaker.NewClass(null, List.<JCExpression>nil(), npe, List.<JCExpression>of(treeMaker.Literal(fieldDecl.name.toString())), null);
- JCStatement throwStatement = treeMaker.Throw(exception);
- JCStatement nullCheck = treeMaker.If(treeMaker.Binary(JCTree.EQ, treeMaker.Ident(fieldDecl.name), treeMaker.Literal(TypeTags.BOT, null)), throwStatement, null);
- statements = List.<JCStatement>of(nullCheck, treeMaker.Exec(assign));
+ statements = List.<JCStatement>of(generateNullCheck(treeMaker, field), treeMaker.Exec(assign));
}
JCBlock methodBody = treeMaker.Block(0, statements);