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

mwKART picture mwKART · Mar 8, 2017 · Viewed 14.1k times · Source

I am having a boolean variable hasObject in lombok which generates isHasObject(). I am using @Data lombok annotation. How can i change the method to hasObject()

Answer

Daij-Djan picture Daij-Djan · Mar 8, 2017

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;
 }

according to the docs:

fluent - A boolean. If true, the getter for pepper is just pepper(), and the setter is pepper(T newValue). Furthermore, unless specified, chain defaults to true. Default: false.