I observed the following strange phenomenon. That lombok
picks setXyz() as setter's name in only three out of the four cases; and in the fourth case, it picks setIsXyz()
package use_lombok;
import lombok.Data;
@Data
public class MyClass {
boolean foo;
Boolean bar;
boolean isBlack;
Boolean isRed;
public static void main(String[] argv) {
MyClass o1 = new MyClass();
o1.setFoo(true);
o1.setBar(true);
o1.setIsRed(true); // This is inconsistent with the others
o1.setBlack(true);
System.out.println(o1.toString());
}
}
Not a duplicate of a previous question
I am aware of the discussion in another StackOverflow Q&A (Lombok annotation @Getter for boolean field), but I am still not happy with the conclusion (that it is the way Lombok is designed). I think Lombok should treat boolean
and Boolean
uniformly.