Re: [project lombok] Feature Request @with

107 views
Skip to first unread message

Mat Jaggard

unread,
Sep 27, 2012, 6:25:19 AM9/27/12
to project...@googlegroups.com
You mean like this...?

http://projectlombok.org/features/experimental/Wither.html

On 26 September 2012 16:28, Usman Ismail <0xff...@gmail.com> wrote:
I have worked on the Amazon AWS Java SDK recently and one of the useful methods I found in its implementation was the withX. this is essentially a setter for the field X which returns the updated object.

It is very useful for chaining updates to an object when you want to use the default constructor to initialize all other fields. 

Something like the code below where field A and D have values overridden an other fields get initialized by the default constructor.
new RandomObject().withFieldA("A Value").withFieldD("D Value");


--
You received this message because you are subscribed to the Google
Groups group for http://projectlombok.org/
 
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-lombo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-lombok?hl=en

Reinier Zwitserloot

unread,
Sep 27, 2012, 6:50:02 AM9/27/12
to project...@googlegroups.com
That's a brilliant idea. Fortunately....

http://projectlombok.org/features/experimental/Wither.html

Usman Ismail

unread,
Sep 28, 2012, 1:37:16 AM9/28/12
to project...@googlegroups.com
Ah :) should have checked the experimental section before posting.

Thx

paouelle

unread,
Sep 24, 2013, 11:30:01 AM9/24/13
to project...@googlegroups.com
Sorry to revive this question but the current @Wither is not exactly the same as what we get with AWS. 

With AWS a wither() simply returns this and doesn't clone the object.

I can understand the need to clone when the fields are final but when they are not, it would be nice to be able to indicate that the wither() should not clone and just return the same object back so we can use for chaining.

Reinier Zwitserloot

unread,
Sep 24, 2013, 12:06:28 PM9/24/13
to project...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages