aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/handlers/HandleData.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-07-11 11:39:45 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-07-11 11:39:45 +0200
commit12d44e59c57e4654a7c61f83baf606a39fbb8448 (patch)
tree03b8666b54830420020fa1697c9a52b22038b0d0 /src/lombok/javac/handlers/HandleData.java
parent98382c6640798846efcc11113116cb46fb820595 (diff)
downloadlombok-12d44e59c57e4654a7c61f83baf606a39fbb8448.tar.gz
lombok-12d44e59c57e4654a7c61f83baf606a39fbb8448.tar.bz2
lombok-12d44e59c57e4654a7c61f83baf606a39fbb8448.zip
'fixed' data up a bit by including only the final fields for the constructor.
Also fixed a bug in javac's toString() generation for the @Data constructor. It did not include the transient fields.
Diffstat (limited to 'src/lombok/javac/handlers/HandleData.java')
-rw-r--r--src/lombok/javac/handlers/HandleData.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lombok/javac/handlers/HandleData.java b/src/lombok/javac/handlers/HandleData.java
index d3974c58..41165600 100644
--- a/src/lombok/javac/handlers/HandleData.java
+++ b/src/lombok/javac/handlers/HandleData.java
@@ -76,7 +76,8 @@ public class HandleData implements JavacAnnotationHandler<Data> {
}
List<Node> nodesForEquality = List.nil();
- List<Node> nodesForConstructorAndToString = List.nil();
+ List<Node> nodesForConstructor = List.nil();
+ List<Node> nodesForToString = List.nil();
for ( Node child : typeNode.down() ) {
if ( child.getKind() != Kind.FIELD ) continue;
JCVariableDecl fieldDecl = (JCVariableDecl) child.get();
@@ -84,21 +85,22 @@ public class HandleData implements JavacAnnotationHandler<Data> {
//Skip static fields.
if ( (fieldFlags & Flags.STATIC) != 0 ) continue;
if ( (fieldFlags & Flags.TRANSIENT) == 0 ) nodesForEquality = nodesForEquality.append(child);
- nodesForConstructorAndToString = nodesForConstructorAndToString.append(child);
+ boolean isFinal = (fieldFlags & Flags.FINAL) != 0;
+ nodesForToString = nodesForToString.append(child);
+ if ( isFinal ) nodesForConstructor = nodesForConstructor.append(child);
new HandleGetter().generateGetterForField(child, annotationNode.get());
- if ( (fieldFlags & Flags.FINAL) == 0 )
- new HandleSetter().generateSetterForField(child, annotationNode.get());
+ if ( !isFinal ) new HandleSetter().generateSetterForField(child, annotationNode.get());
}
String staticConstructorName = annotation.getInstance().staticConstructor();
if ( constructorExists(typeNode) == MemberExistsResult.NOT_EXISTS ) {
- JCMethodDecl constructor = createConstructor(staticConstructorName.equals(""), typeNode, nodesForConstructorAndToString);
+ JCMethodDecl constructor = createConstructor(staticConstructorName.equals(""), typeNode, nodesForConstructor);
injectMethod(typeNode, constructor);
}
if ( !staticConstructorName.isEmpty() && methodExists("of", typeNode) == MemberExistsResult.NOT_EXISTS ) {
- JCMethodDecl staticConstructor = createStaticConstructor(staticConstructorName, typeNode, nodesForConstructorAndToString);
+ JCMethodDecl staticConstructor = createStaticConstructor(staticConstructorName, typeNode, nodesForConstructor);
injectMethod(typeNode, staticConstructor);
}
@@ -113,7 +115,7 @@ public class HandleData implements JavacAnnotationHandler<Data> {
}
if ( methodExists("toString", typeNode) == MemberExistsResult.NOT_EXISTS ) {
- JCMethodDecl method = createToString(typeNode, nodesForEquality);
+ JCMethodDecl method = createToString(typeNode, nodesForToString);
injectMethod(typeNode, method);
}