@Accessors(chain = true) should work with inheritance

3,994 views
Skip to first unread message

Bruno Bonanno

unread,
Apr 28, 2015, 12:27:37 PM4/28/15
to project...@googlegroups.com
Hi there, I found something that would be very useful in my opinion

When you use @Accessors(chain = true) and you have a hierarchy present you can not chain parent setters with child setters cause the return type in the first ones is the parent class so when you want to start working with the child setters it doesn't work
A solution could be overriding the parent setters to change the return type, and so all the setters related to a class return the same type
@Builder has a similar problem, it doesn't include all the fields in the hierarchy

I'm missing something or is a genuine feature request?

Thanks

Bruno

Reinier Zwitserloot

unread,
Apr 29, 2015, 5:14:30 PM4/29/15
to project-lombok
Doing this would require resolution (knowing the structure of your supertype, which requires analysing that source file, etc). This results in chicken and egg issues: If lombok lets the compilation process advance that far, it's too late to add getters and setters and such, but if we don't, we don't know what the parent class has.

There are solutions to this (val and @Delegate and @ExtensionMethod employ them), but the number of bugs, subtleties, and performance issues that those features entail is already a fairly heavy support load for us at the moment. Until we get a lot better at doing resolution properly and quickly, @Data and friends will not be using resolution, even in cases where it would be rather nice, such as here.

 --Reinier Zwitserloot

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bruno Bonanno

unread,
May 5, 2015, 2:40:27 PM5/5/15
to project...@googlegroups.com
Fair enough

Thanks for the answer!

Bruno
Reply all
Reply to author
Forward
0 new messages