After scouring the Lombok feature-list and in particular the documentation for the Getter/Setter and @Value
annotations I have not been able to find any setting that suppresses the code generated by @Getter
.
In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter
This is important as I do not want to leak references to objects that are themselves mutable.
Effective Java references this type of issue in "Item 39: Make defensive copies when needed". It seems that @Wither
could partly solve this issue by making actual defensive copies but I want to avoid leaking attributes what so ever, regardless of them being mutable.
While it is possible to roll one's own @Value
annotation that omits the @Getter
I would, of course, prefer not to as that would add unwarranted complexity to the codebase if such a setting already exists.
You could use:
@Value @Getter(AccessLevel.NONE)
AccessLevel.NONE
instructs Lombok to not generate the getters. That's the best you can do right now.