Change the method name of the lombok method for the logical member with the prefix "has"

I have a boolean variable hasObjectin lombok that generates isHasObject(). I am using the @Data lombok annotation. How to change the method tohasObject()

+4
source share
2 answers

I found out about the help of lombok-how-to-customize-getter-for-boolean-object-field . To this I will have a varying access level and an old version of getter code,

@Getter(AccessLevel.NONE) private boolean hasObject;

public boolean hasObject() {
    return hasObject;
}

I will keep this question open. This is the only way to change the getter method name, or I will wait for the best offers.

+1
source

in your case it could be:

 class XY : Object {
      @Getter(fluent = true)
      public boolean hasObject;
 }

OR

 @Accessors(fluent = true)
 class XY : Object {
      public boolean hasObject;
 }

in accordance with the documents:

- . , - (), - (T newValue). , , true. : false.

+2

Source: https://habr.com/ru/post/1671796/


All Articles