diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-09-03 01:44:59 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-09-03 01:44:59 +0200 |
commit | f1124aad02569c983cb8979445245141bf029a88 (patch) | |
tree | 80d25bb1dddcfce46931f298b6f70ebdbd2e3e13 /src/lombok/javac/handlers/PKG.java | |
parent | 6b7919166e9a550d7d2b1f7156c794e76905fcab (diff) | |
download | lombok-f1124aad02569c983cb8979445245141bf029a88.tar.gz lombok-f1124aad02569c983cb8979445245141bf029a88.tar.bz2 lombok-f1124aad02569c983cb8979445245141bf029a88.zip |
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.
Diffstat (limited to 'src/lombok/javac/handlers/PKG.java')
-rw-r--r-- | src/lombok/javac/handlers/PKG.java | 26 |
1 files changed, 26 insertions, 0 deletions
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<Integer> createListOfNonExistentFields(List<String> 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<Integer> problematic = List.nil(); + for ( int i = 0 ; i < list.size() ; i++ ) { + if ( !matched[i] ) problematic = problematic.append(i); + } + + return problematic; + } + } |