aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2015-11-23 03:12:50 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2015-11-23 03:12:50 +0100
commit728ae6421dd03bc78e37c0eb5d860f932b5fff2c (patch)
treeefa7ca8635f4d897ebf5fb7a5733e0a17ae6e6a3 /src/core/lombok/javac
parentb8ced807a79660eef87f1833d1ec95d774a4f4a2 (diff)
downloadlombok-728ae6421dd03bc78e37c0eb5d860f932b5fff2c.tar.gz
lombok-728ae6421dd03bc78e37c0eb5d860f932b5fff2c.tar.bz2
lombok-728ae6421dd03bc78e37c0eb5d860f932b5fff2c.zip
[Fixes #965] Adds a config key to automatically determine the behaviour of equals and hashCode generation when
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index 4bc79f03..f41fbd2f 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -32,6 +32,7 @@ import java.util.Collections;
import lombok.ConfigurationKeys;
import lombok.EqualsAndHashCode;
import lombok.core.AST.Kind;
+import lombok.core.configuration.CallSuperType;
import lombok.core.AnnotationValues;
import lombok.core.handlers.HandlerUtil;
import lombok.javac.Javac;
@@ -158,8 +159,23 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
return;
}
- if (!isDirectDescendantOfObject && !callSuper && implicitCallSuper) {
- source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
+ if (implicitCallSuper && !isDirectDescendantOfObject) {
+ CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ if (cst == null) cst = CallSuperType.WARN;
+
+ switch (cst) {
+ default:
+ case WARN:
+ source.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
+ callSuper = false;
+ break;
+ case SKIP:
+ callSuper = false;
+ break;
+ case CALL:
+ callSuper = true;
+ break;
+ }
}
ListBuffer<JavacNode> nodesForEquality = new ListBuffer<JavacNode>();