Lombok: [Suggestion] Override Getter/Setter annotations

Created on 16 Feb 2016  ·  3Comments  ·  Source: projectlombok/lombok

It would be nice if you would implement overriding getter/setter annotations. For example:

@Getter
public class Example {

    private int a;

    public int getA() { //override to avoid npe
         return a < 0 ? -1 : a; 
    }    

}

Most helpful comment

Just do it. No getter gets generated if there's already one present.

You can also use @Getter(AccessLevel.NONE) to disable the generation explicitly.

All 3 comments

Just do it. No getter gets generated if there's already one present.

You can also use @Getter(AccessLevel.NONE) to disable the generation explicitly.

Well then it is an issue of IntelliJ IDEA plugin, which warns me that I cannot have @Getter and simple getter together. Thank you for the answer!

AFAIK, there should be no such warning unless the annotation surely generates no getters at all (a field-level annotation together with the manual getter should produce a warning; a class-level annotation should not).

Was this page helpful?
0 / 5 - 0 ratings