You can pass an access level to the @Getter
and @Setter
annotations. This is useful to make getters or setters protected or private. It can also be used to override the default.
With @Data
, you have public access to the accessors by default. You can now use the special access level NONE
to completely omit the accessor, like this:
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private int mySecret;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…