From 3d32cd85f174bbeb54ea0c102e029c42daf51931 Mon Sep 17 00:00:00 2001 From: Christian Sterzl Date: Thu, 3 Apr 2014 08:11:16 +0200 Subject: Adding onParam to annotation @EqualsAndHashCode to add individual annotations to the parameters of equals and canEqual. --- .../javac/handlers/HandleEqualsAndHashCode.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/core/lombok/javac') diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index 05244f3b..e62b0555 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -94,7 +94,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler excludes = List.from(ann.exclude()); List includes = List.from(ann.of()); JavacNode typeNode = annotationNode.up(); - + List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@EqualsAndHashCode(onParam=", annotationNode); checkForBogusFieldNames(typeNode, annotation); Boolean callSuper = ann.callSuper(); @@ -109,7 +109,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler excludes, List includes, - Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess) { + Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess, List onParam) { boolean notAClass = true; if (typeNode.get() instanceof JCClassDecl) { long flags = ((JCClassDecl)typeNode.get()).mods.flags; @@ -210,11 +210,11 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source) { + public JCMethodDecl createEquals(JavacNode typeNode, List fields, boolean callSuper, FieldAccess fieldAccess, boolean needsCanEqual, JCTree source, List onParam) { JavacTreeMaker maker = typeNode.getTreeMaker(); JCClassDecl type = (JCClassDecl) typeNode.get(); @@ -379,7 +379,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler statements = new ListBuffer(); - final List params = List.of(maker.VarDef(maker.Modifiers(finalFlag | Flags.PARAMETER), oName, objectType, null)); + final List params = List.of(maker.VarDef(maker.Modifiers(finalFlag | Flags.PARAMETER, onParam), oName, objectType, null)); /* if (o == this) return true; */ { statements.append(maker.If(maker.Binary(CTC_EQUAL, maker.Ident(oName), @@ -497,7 +497,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandlernil(), params, List.nil(), body, null), source, typeNode.getContext()); } - public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source) { + public JCMethodDecl createCanEqual(JavacNode typeNode, JCTree source, List onParam) { /* public boolean canEqual(final java.lang.Object other) { * return other instanceof Outer.Inner.MyType; * } @@ -510,7 +510,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler params = List.of(maker.VarDef(maker.Modifiers(flags), otherName, objectType, null)); + List params = List.of(maker.VarDef(maker.Modifiers(flags, onParam), otherName, objectType, null)); JCBlock body = maker.Block(0, List.of( maker.Return(maker.TypeTest(maker.Ident(otherName), createTypeReference(typeNode))))); -- cgit