From f1124aad02569c983cb8979445245141bf029a88 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 3 Sep 2009 01:44:59 +0200 Subject: Addressed issue #32: The @EqualsAndHashCode and @ToString annotations now support explicitly listing the fields to use, via the new 'of' parameter. We've also added any fields that start with $ to the default excludes list. Lombok itself can generate these fields ($lock of @Synchronized, for example), and in general they probably should count as effectively not part of the class. --- src/lombok/javac/handlers/PKG.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/lombok/javac/handlers/PKG.java') diff --git a/src/lombok/javac/handlers/PKG.java b/src/lombok/javac/handlers/PKG.java index 4b05b9ae..0563f33c 100644 --- a/src/lombok/javac/handlers/PKG.java +++ b/src/lombok/javac/handlers/PKG.java @@ -288,4 +288,30 @@ class PKG { JCStatement throwStatement = treeMaker.Throw(exception); return treeMaker.If(treeMaker.Binary(JCTree.EQ, treeMaker.Ident(fieldName), treeMaker.Literal(TypeTags.BOT, null)), throwStatement, null); } + + static List createListOfNonExistentFields(List list, Node type, boolean excludeStandard, boolean excludeTransient) { + boolean[] matched = new boolean[list.size()]; + + for ( Node child : type.down() ) { + if ( list.isEmpty() ) break; + if ( child.getKind() != Kind.FIELD ) continue; + JCVariableDecl field = (JCVariableDecl)child.get(); + if ( excludeStandard ) { + if ( (field.mods.flags & Flags.STATIC) != 0 ) continue; + if ( field.name.toString().startsWith("$") ) continue; + } + if ( excludeTransient && (field.mods.flags & Flags.TRANSIENT) != 0 ) continue; + + int idx = list.indexOf(child.getName()); + if ( idx > -1 ) matched[idx] = true; + } + + List problematic = List.nil(); + for ( int i = 0 ; i < list.size() ; i++ ) { + if ( !matched[i] ) problematic = problematic.append(i); + } + + return problematic; + } + } -- cgit