Reputation: 1006
How can I replace the getters in the following example using Lombok?
import lombok.Builder;
public class MyClass {
private MyBasicDataClass basicData = MyBasicDataClass.builder().myInt(10).myBool(true).build();
public Integer getMyInt() {
return basicData.myInt;
}
public Boolean getMyBool() {
return basicData.myBool;
}
@Builder
static class MyBasicDataClass {
private Integer myInt;
private Boolean myBool;
}
}
The basicData property cannot be replaced.
Upvotes: 3
Views: 2069
Reputation: 8142
This is not possible with Lombok, you have to implement it manually.
You might ask yourself if Lombok could be improved to support such a feature. The answer is: Probably not. In most cases similar to this people want to refer to another (top-level) class, not an inner class. Annotation processors like Lombok do not have access to anything outside the compilation unit they are currently processing. That makes it technically very difficult, probably impossible to implement such a feature in Lombok.
Upvotes: 1