projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.86k stars 2.38k forks source link

fluent setters #270

Closed lombokissues closed 9 years ago

lombokissues commented 9 years ago

Migrated from Google Code (issue 197)

lombokissues commented 9 years ago

:bust_in_silhouette: jmsachs   :clock8: Feb 23, 2011 at 20:31 UTC

(mentioned in the Google Groups a few times but doesn't seem to be in the issues list)

plain Java:

class Foo { private int x; private String s;

public Foo setX(int x) { this.x = x; } public Foo setS(String s) { this.s = s; } }

use case:

Foo foo = new Foo().setX(3).setS("something");

http://groups.google.com/group/project-lombok/browse_thread/thread/5fc7a78e3afed9d8/c203fb9e577d06a4

http://groups.google.com/group/project-lombok/browse_thread/thread/303ebf903908bf7/91d339234766c9cb

If this is part of the @ Builder implementation (issue #89), and the fluent setters are easier to implement than the @ Builder, please release this one first.

lombokissues commented 9 years ago

:bust_in_silhouette: jmsachs   :clock8: Feb 23, 2011 at 20:32 UTC

(this should have been an enhancement, not a defect, sorry)

lombokissues commented 9 years ago

:bust_in_silhouette: jmsachs   :clock8: Feb 23, 2011 at 20:35 UTC

Darn -- I just noticed issue #88. This is a duplicate.

But again, if it's easier to implement than the full @ Builder, please release this first.

lombokissues commented 9 years ago

:bust_in_silhouette: r.spilker   :clock8: May 09, 2011 at 19:31 UTC

lombokissues commented 9 years ago

:bust_in_silhouette: reinierz   :clock8: May 09, 2011 at 20:58 UTC

lombokissues commented 9 years ago

:bust_in_silhouette: reinierz   :clock8: May 09, 2011 at 20:58 UTC

Duplicate of issue #88

lombokissues commented 9 years ago

:bust_in_silhouette: matt@thebishops.org   :clock8: Aug 17, 2013 at 19:55 UTC

Please reopen.

There is a difference between Builder and Fluent; please add a @ Fluent along the lines of this:

http://martinfowler.com/bliki/FluentInterface.html

The main problem with builder is the build() method. I just want to make a @ Data class with chainable set() methods, not a Builder. The reason for this is that the Data class gets passed up several levels and is manipulated along the way. I'd rather not pass a builder but instead a DTO with fluent setters.

lombokissues commented 9 years ago

:bust_in_silhouette: askoning   :clock8: Aug 18, 2013 at 09:41 UTC

@ Accessors(fluent=true) should do the trick for you.

Please see https://projectlombok.org/features/experimental/Accessors.html

lombokissues commented 9 years ago

:bust_in_silhouette: r.spilker   :clock8: Aug 21, 2013 at 15:43 UTC

Or @ Wither: https://projectlombok.org/features/experimental/Wither.html

lombokissues commented 9 years ago

End of migration