Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluent setters #270

Closed
lombokissues opened this issue Jul 14, 2015 · 10 comments
Closed

fluent setters #270

lombokissues opened this issue Jul 14, 2015 · 10 comments

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 197)

@lombokissues
Copy link
Author

👤 jmsachs   🕗 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
Copy link
Author

👤 jmsachs   🕗 Feb 23, 2011 at 20:32 UTC

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

@lombokissues
Copy link
Author

👤 jmsachs   🕗 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
Copy link
Author

👤 r.spilker   🕗 May 09, 2011 at 19:31 UTC

@lombokissues
Copy link
Author

👤 reinierz   🕗 May 09, 2011 at 20:58 UTC

@lombokissues
Copy link
Author

👤 reinierz   🕗 May 09, 2011 at 20:58 UTC

Duplicate of issue #88

@lombokissues
Copy link
Author

👤 matt@thebishops.org   🕗 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
Copy link
Author

👤 askoning   🕗 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
Copy link
Author

👤 r.spilker   🕗 Aug 21, 2013 at 15:43 UTC

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

@lombokissues
Copy link
Author

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant