Lombok annotation @Getter for boolean field

Nitesh Kumar :

I am using Java lombok annotation @Getter to generate getters for my POJO. I have a 'boolean' field by the name 'isAbc'. The @Getter annotation in this case generates a method by the name 'isAbc()'. Shouldn't it generate a method by the name 'isIsAbc()'?

Harald Gliebe :

Read the 'small print' section on the lombok page https://projectlombok.org/features/GetterSetter.html

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

So the behavior you experience is as specified.

Note that the behavior is different for boolean and Boolean:

@Getter
private boolean isGood; // => isGood()

@Getter
private boolean good; // => isGood()

@Getter
private Boolean isGood; // => getIsGood()

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Default field value with @Builder or @Getter annotation in Lombok

Lombok how to customise getter for Boolean object field?

Make Thymeleaf th:field consume Lombok-generated boolean getter

Java Lombok "@Getter" is not applicable to field

Project Lombok - Value annotation: is it possible to suppress @Getter?

Django query annotation with boolean field

Lombok Constructor annotation with a single custom field initialization

Edit lombok getter method name for boolean member having prefix "has"

Gets all fields with a specific annotation on the field or the getter

@JsonProperty annotation on field as well as getter/setter

Lombok not working with "Android room". Gives "error: Cannot find getter for field"

Jackson annotation unable to parse boolean field

Lombok won't generate getter methods for variables when annotation is in class level

Use jackson annotation JsonUnwrapped on a field with name different from its getter

For a boolean field, what is the naming convention for its getter/setter?

Lombok @Getter and copies of Collections

Lombok - access to getter not visible

Lombok is not generating getter and setter

Lombok not generating getter and setter?

SonarQube Lombok Getter recognition

Django 4 how to do annotation over boolean field queryset?

How can I configure getter-only-lazy-initializing collection field with lombok?

How to turn off getter/setter only for one instance non-final field? [Project Lombok]

@NonNull annotation in project Lombok

Create custom annotation for Lombok

Annotation for various constructors in Lombok?

Use of Lombok @SneakyThrows annotation

Lombok Requires Annotation Processing

Why 3rd party REST API's gets null values for request fields when removing @Getter Lombok annotation