aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
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/eclipse
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/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 77fe3a52..53785845 100644
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -39,6 +39,7 @@ import lombok.EqualsAndHashCode;
import lombok.core.AST.Kind;
import lombok.core.handlers.HandlerUtil;
import lombok.core.AnnotationValues;
+import lombok.core.configuration.CallSuperType;
import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseAnnotationHandler;
import lombok.eclipse.EclipseNode;
@@ -185,8 +186,23 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
return;
}
- if (!isDirectDescendantOfObject && !callSuper && implicitCallSuper) {
- errorNode.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:
+ errorNode.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;
+ }
}
List<EclipseNode> nodesForEquality = new ArrayList<EclipseNode>();