From 0e673c6b3004a67c760bcbbabdc8abbf35c70722 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 22 May 2014 03:30:01 +0200 Subject: added conf keys (and implementation to make them work) for lombok.getter.lazy.flagUsage and lombok.equalsAndHashCode.doNotUseGetters. --- src/core/lombok/ConfigurationKeys.java | 14 ++++++++++++++ .../lombok/eclipse/handlers/HandleEqualsAndHashCode.java | 4 +++- src/core/lombok/eclipse/handlers/HandleGetter.java | 6 +++--- .../lombok/javac/handlers/HandleEqualsAndHashCode.java | 4 +++- src/core/lombok/javac/handlers/HandleGetter.java | 6 +++--- 5 files changed, 26 insertions(+), 8 deletions(-) (limited to 'src/core/lombok') diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index dd339301..608bedd1 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -103,6 +103,13 @@ public class ConfigurationKeys { */ public static final ConfigurationKey GETTER_FLAG_USAGE = new ConfigurationKey("lombok.getter.flagUsage", "Emit a warning or error if @Getter is used.") {}; + /** + * lombok configuration: {@code lombok.getter.lazy.flagUsage} = {@code WARNING} | {@code ERROR}. + * + * If set, any usage of {@code @Getter(lazy=true)} results in a warning / error. + */ + public static final ConfigurationKey GETTER_LAZY_FLAG_USAGE = new ConfigurationKey("lombok.getter.lazy.flagUsage", "Emit a warning or error if @Getter(lazy=true) is used.") {}; + // ----- Setter ----- /** @@ -114,6 +121,13 @@ public class ConfigurationKeys { // ----- EqualsAndHashCode ----- + /** + * lombok configuration: {@code lombok.equalsAndHashCode.doNotUseGetters} = {@code true} | {@code false}. + * + * For any class without an {@code @EqualsAndHashCode} that explicitly defines the {@code doNotUseGetters} option, this value is used. + */ + public static final ConfigurationKey EQUALS_AND_HASH_CODE_DO_NOT_USE_GETTERS = new ConfigurationKey("lombok.equalsAndHashCode.doNotUseGetters", "Don't call the getters but use the fields directly in the generated equalsAndHashCode method.") {}; + /** * lombok configuration: {@code lombok.equalsAndHashCode.flagUsage} = {@code WARNING} | {@code ERROR}. * diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index f34e70b9..e1b02051 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -140,7 +140,9 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler { Getter annotationInstance = annotation.getInstance(); AccessLevel level = annotationInstance.value(); boolean lazy = annotationInstance.lazy(); + if (lazy) handleFlagUsage(annotationNode, ConfigurationKeys.GETTER_LAZY_FLAG_USAGE, "@Getter(lazy=true)"); + if (level == AccessLevel.NONE) { - if (lazy) { - annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE."); - } + if (lazy) annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE."); return; } diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java index d267a29a..1a6f4a8f 100644 --- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java @@ -107,7 +107,9 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler { Getter annotationInstance = annotation.getInstance(); AccessLevel level = annotationInstance.value(); boolean lazy = annotationInstance.lazy(); + if (lazy) handleFlagUsage(annotationNode, ConfigurationKeys.GETTER_LAZY_FLAG_USAGE, "@Getter(lazy=true)"); + if (level == AccessLevel.NONE) { - if (lazy) { - annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE."); - } + if (lazy) annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE."); return; } -- cgit