Feature: Encapsulation and collections using the Delegate annotation

12 views
Skip to first unread message

Timothy Spear

unread,
Mar 9, 2026, 8:15:14 AM (5 days ago) Mar 9
to Project Lombok
In an ideal world, we are supposed to encapsulate collections/sets and other attributes within the object and not expose it.
Doing so requires fairly extensive boilerplate code; which is why I never bother doing it. Based on searching, I think that has come up more than once, but most of the requests I found were rather old. 

However, I have yet to see any suggestions to do tied to the Delegate annotation. 

With two (what I hope are minor) changes the existing delegate annotation could do the job. 
Add two attributes to Delegate:
1. prefix 
2. methodMap

If prefix is enabled, generate the new method name by appending the variable to the method name from the interface, following the same logic as Getter/Setter.
MethodMap would allow for name changes. e.g. I would want to standardize "add" as my public method name, and map it to "put", for example.

Tim
Reply all
Reply to author
Forward
0 new messages