3

Normally in Lombok the documentation that shows up in getters and setters are inherited from the field. But I have a class that needs to have an interface. In Java interfaces do not have fields and so I must define the fields in the concrete class. How do I make sure I do not duplicate documentation but still have the documentation associated with the field?

In code

@Data
public class MyClass implements MyInterface{
    /**
    *My doc
    */
    final private List<String> myField;
}

public interface MyInterface{
    public List<String> getMyField();
}
Nouvel Travay
  • 6,292
  • 13
  • 40
  • 65
  • No lock when used exactly like you did in the example? Never seen an option for that so you may have to write the getter&setter manually – zapl May 11 '16 at 23:07
  • If I implement getter and setter myself, then I would still have to duplicate my comments – Nouvel Travay May 13 '16 at 02:56

1 Answers1

3

Did you try to add {@inheritDoc} to the javadoc on the field in the -- GETTER -- section as described in the documentation and have the javadoc for getMyField only in the interface?

Disclosure: I am a lombok developer.

Roel Spilker
  • 32,258
  • 10
  • 68
  • 58