Lombok annotation @Getter for boolean field

拜拜、爱过 提交于 2019-11-28 09:00:43
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()
Sunny

I do some tests against the lombok(1.16.8), and the conclusions are as below.

private Boolean good;

getter => getGood()              Boolean
setter => setGood(Boolean good)  void 


private boolean good;

getter => isGood()               boolean
setter => setGood(boolean good)  void 


private Boolean isGood;

getter => getIsGood()            Boolean
setter => setIsGood()            void 


private boolean isGood;

getter => isGood()               boolean
setter => setGood(boolean good)  void
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!