From 1c323332493148f0aaa936e668e1b0da5d09c8be Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 11 Nov 2010 01:58:48 +0100 Subject: @Getter(lazy=true) support for javac --- .../javac/handlers/HandleEqualsAndHashCode.java | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java') diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index 60b0f89f..e076b295 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -90,7 +90,9 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler excludes, List includes, - Boolean callSuper, boolean whineIfExists, boolean useFieldsDirectly) { + Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess) { boolean notAClass = true; if (typeNode.get() instanceof JCClassDecl) { long flags = ((JCClassDecl)typeNode.get()).mods.flags; @@ -173,7 +175,7 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler fields, boolean callSuper, boolean useFieldsDirectly) { + private JCMethodDecl createHashCode(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess) { TreeMaker maker = typeNode.getTreeMaker(); JCAnnotation overrideAnnotation = maker.Annotation(chainDots(maker, typeNode, "java", "lang", "Override"), List.nil()); @@ -247,8 +249,8 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandlernil(), hcMethod, List.of(fieldAccessor))); } else /* objects */ { /* this.fieldName == null ? 0 : this.fieldName.hashCode() */ - JCExpression hcCall = maker.Apply(List.nil(), maker.Select(createFieldAccessor(maker, fieldNode, useFieldsDirectly), typeNode.toName("hashCode")), + JCExpression hcCall = maker.Apply(List.nil(), maker.Select(createFieldAccessor(maker, fieldNode, fieldAccess), typeNode.toName("hashCode")), List.nil()); JCExpression thisEqualsNull = maker.Binary(JCTree.EQ, fieldAccessor, maker.Literal(TypeTags.BOT, null)); intoResult = intoResult.append( @@ -329,7 +331,7 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler fields, boolean callSuper, boolean useFieldsDirectly, boolean needsCanEqual) { + private JCMethodDecl createEquals(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual) { TreeMaker maker = typeNode.getTreeMaker(); JCClassDecl type = (JCClassDecl) typeNode.get(); @@ -398,9 +400,9 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandlernil(), - maker.Select(createFieldAccessor(maker, fieldNode, useFieldsDirectly), typeNode.toName("equals")), - List.of(createFieldAccessor(maker, fieldNode, useFieldsDirectly, maker.Ident(otherName)))); + maker.Select(createFieldAccessor(maker, fieldNode, fieldAccess), typeNode.toName("equals")), + List.of(createFieldAccessor(maker, fieldNode, fieldAccess, maker.Ident(otherName)))); JCExpression fieldsAreNotEqual = maker.Conditional(thisEqualsNull, otherNotEqualsNull, maker.Unary(JCTree.NOT, thisEqualsThat)); statements = statements.append(maker.If(fieldsAreNotEqual, returnBool(maker, false), null)); } -- cgit