From 627de194c03af3afa3478149dc777d2af4e9654b Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 1 Jun 2014 11:01:58 +0200 Subject: fixed up ‘consequent boolean’ proposal with a different key name and documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/lombok/ConfigurationKeys.java | 8 ++++---- src/core/lombok/core/handlers/HandlerUtil.java | 1 - website/features/GetterSetter.html | 22 ++++++++-------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index e3308f0a..301563b8 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -112,12 +112,12 @@ 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. + * lombok configuration: {@code lombok.getter.noIsPrefix} = {@code true} | {@code false}. + * + * If {@code true}, booleans getters are both referred to, and generated as {@code getFieldName()}. If {@code false} (the default), the javabean-standard {@code isFieldName()} is generated / used instead. * */ - public static final ConfigurationKey GETTER_CONSEQUENT_BOOLEAN = new ConfigurationKey("lombok.getter.consequentBoolean", "Emit a warning or error if @Getter is used.") {}; + public static final ConfigurationKey GETTER_CONSEQUENT_BOOLEAN = new ConfigurationKey("lombok.getter.noIsPrefix", "If true, generate and use getFieldName() for boolean getters instead of isFieldName().") {}; // ----- Setter ----- diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index 03bb341c..621d8760 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -285,7 +285,6 @@ public class HandlerUtil { 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"); Accessors ac = (explicitPrefix || explicitFluent) ? accessors.getInstance() : null; diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html index a0da405d..ad83f86a 100644 --- a/website/features/GetterSetter.html +++ b/website/features/GetterSetter.html @@ -16,18 +16,13 @@

Overview

You can annotate any field with @Getter and/or @Setter, to let lombok generate the default getter/setter automatically.
- A default getter simply returns the field, and is named getFoo if the field is called foo (or isFoo - if the field's type is boolean). A default setter is named setFoo if the field is called foo, returns void, - and takes 1 parameter of the same type as the field. It simply sets the field to this value. + A default getter simply returns the field, and is named getFoo if the field is called foo (or isFoo if the field's type is boolean). A default setter is named setFoo if the field is called foo, returns void, and takes 1 parameter of the same type as the field. It simply sets the field to this value.

- The generated getter/setter method will be public unless you explicitly specify an AccessLevel, as shown in the example below. - Legal access levels are PUBLIC, PROTECTED, PACKAGE, and PRIVATE. + The generated getter/setter method will be public unless you explicitly specify an AccessLevel, as shown in the example below. Legal access levels are PUBLIC, PROTECTED, PACKAGE, and PRIVATE.

- You can also put a @Getter and/or @Setter annotation on a class. In that case, it's as if you annotate all the non-static fields in that - class with the annotation. + You can also put a @Getter and/or @Setter annotation on a class. In that case, it's as if you annotate all the non-static fields in that class with the annotation.

- You can always manually disable getter/setter generation for any field by using the special AccessLevel.NONE access level. This lets you override the - behaviour of a @Getter, @Setter or @Data annotation on a class. + You can always manually disable getter/setter generation for any field by using the special AccessLevel.NONE access level. This lets you override the behaviour of a @Getter, @Setter or @Data annotation on a class.

To put annotations on the generated method, you can use onMethod=@__({@AnnotationsHere}); to put annotations on the only parameter of a generated setter method, you can use onParam=@__({@AnnotationsHere}). Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.

@@ -55,6 +50,8 @@

If set to true, generated getters and setters will not be prefixed with the bean-standard 'get, is or set; instead, the methods will use the same name as the field (minus prefixes). An explicitly configured chain parameter of an @Accessors annotation takes precedence over this setting.
lombok.accessors.prefix += a field prefix (default: empty list)
This is a list property; entries can be added with the += operator. Inherited prefixes from parent config files can be removed with the -= operator. Lombok will strip any matching field prefix from the name of a field in order to determine the name of the getter/setter to generate. For example, if m is one of the prefixes listed in this setting, then a field named mFoobar will result in a getter named getFoobar(), not getMFoobar(). An explicitly configured prefix parameter of an @Accessors annotation takes precedence over this setting.
+
lombok.getter.noIsPrefix = [true | false] (default: false)
+
If set to true, getters generated for boolean fields will use the get prefix instead of the defaultis prefix, and any generated code that calls getters, such as @ToString, will also use get instead of is
lombok.setter.flagUsage = [warning | error] (default: not set)
Lombok will flag any usage of @Setter as a warning or error if configured.
lombok.getter.flagUsage = [warning | error] (default: not set)
@@ -64,12 +61,9 @@

Small print

- For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified. - Then, get/set/is is prefixed. + For generating the method names, the first character of the field, if it is a lowercase character, is title-cased, otherwise, it is left unmodified. Then, get/set/is is prefixed.

- No method is generated if any method already exists with the same name (case insensitive) and same parameter count. For example, getFoo() - will not be generated if there's already a method getFoo(String... x) even though it is technically possible to make the method. This caveat - exists to prevent confusion. If the generation of a method is skipped for this reason, a warning is emitted instead. Varargs count as 0 to N parameters. + No method is generated if any method already exists with the same name (case insensitive) and same parameter count. For example, getFoo() will not be generated if there's already a method getFoo(String... x) even though it is technically possible to make the method. This caveat exists to prevent confusion. If the generation of a method is skipped for this reason, a warning is emitted instead. Varargs count as 0 to N parameters. You can mark any method with @lombok.experimental.Tolerate to hide them from lombok.

For boolean fields that start with is immediately followed by a title-case letter, nothing is prefixed to generate the getter name.

-- cgit