From 329b2be3d9087cc7f02a68267ced5f16254c6362 Mon Sep 17 00:00:00 2001 From: Maaartin Grajcar Date: Thu, 22 May 2014 20:35:36 +0200 Subject: Create GETTER_CONSEQUENT_BOOLEAN. --- src/core/lombok/ConfigurationKeys.java | 8 ++++++++ src/core/lombok/core/handlers/HandlerUtil.java | 2 ++ 2 files changed, 10 insertions(+) (limited to 'src/core/lombok') diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 427c5f83..e3308f0a 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -111,6 +111,14 @@ public class ConfigurationKeys { */ 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.") {}; + /** + * lombok configuration: {@code lombok.getter.consequentBoolean} = {@code true} | {@code false}. + * + * If true, the special Javabeans rules for {@code boolean} accessors get ignored and booleans get processed just like any other type. + * + */ + public static final ConfigurationKey GETTER_CONSEQUENT_BOOLEAN = new ConfigurationKey("lombok.getter.consequentBoolean", "Emit a warning or error if @Getter is used.") {}; + // ----- Setter ----- /** diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 0d48b624..03bb341c 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -283,6 +283,7 @@ public class HandlerUtil { fieldName = fieldName.toString(); if (fieldName.length() == 0) return null; + if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false; boolean explicitPrefix = accessors != null && accessors.isExplicit("prefix"); // System.out.printf("accessors: %s actual expr: %s val: %s\n", accessors, accessors != null ? accessors.getActualExpression("prefix") : "(null)", accessors == null ? "(null)" : Arrays.toString(accessors.getInstance().prefix())); boolean explicitFluent = accessors != null && accessors.isExplicit("fluent"); @@ -351,6 +352,7 @@ public class HandlerUtil { private static List toAllAccessorNames(AST ast, AnnotationValues accessors, CharSequence fieldName, boolean isBoolean, String booleanPrefix, String normalPrefix, boolean adhereToFluent) { + if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false; if (!isBoolean) { String accessorName = toAccessorName(ast, accessors, fieldName, false, booleanPrefix, normalPrefix, adhereToFluent); return (accessorName == null) ? Collections.emptyList() : Collections.singletonList(accessorName); -- cgit