diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-25 05:33:04 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-25 05:33:04 +0200 |
commit | dec4be37381caaf4e2ec9af301153734088889fd (patch) | |
tree | 503f8b866896935e845c0714b7d9de25515084a2 | |
parent | 63894b98dd648ab5b83dd7bc57defb1dbcfd97ae (diff) | |
download | lombok-dec4be37381caaf4e2ec9af301153734088889fd.tar.gz lombok-dec4be37381caaf4e2ec9af301153734088889fd.tar.bz2 lombok-dec4be37381caaf4e2ec9af301153734088889fd.zip |
Removed adding the statement: 'final int PRIME = 31;' in the HandleData's createHashCode method when there are 0 fields in the type (it would generate a local variable never used warning!)
-rw-r--r-- | src/lombok/eclipse/handlers/HandleData.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java index e90f33fd..c65ea5cf 100644 --- a/src/lombok/eclipse/handlers/HandleData.java +++ b/src/lombok/eclipse/handlers/HandleData.java @@ -449,13 +449,16 @@ public class HandleData implements EclipseAnnotationHandler<Data> { final char[] PRIME = "PRIME".toCharArray(); final char[] RESULT = "result".toCharArray(); + final boolean isEmpty = fields.isEmpty(); /* final int PRIME = 31; */ { - LocalDeclaration primeDecl = new LocalDeclaration(PRIME, 0 ,0); - primeDecl.modifiers = Modifier.FINAL; - primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); - primeDecl.initialization = new IntLiteral("31".toCharArray(), 0, 0); - statements.add(primeDecl); + if ( !isEmpty ) { /* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */ + LocalDeclaration primeDecl = new LocalDeclaration(PRIME, 0 ,0); + primeDecl.modifiers = Modifier.FINAL; + primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0); + primeDecl.initialization = new IntLiteral("31".toCharArray(), 0, 0); + statements.add(primeDecl); + } } /* int result = 1; */ { |