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()
From Lombok documentation: 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 override the access level, annotate the field or class with an explicit @Setter and/or @Getter annotation. You can also use this annotation (by combining it with AccessLevel. NONE) to suppress generating a getter and/or setter altogether. Show activity on this post.
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 ).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With