lishunli / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

fluent setters #197

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
(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/5fc7a78e3afed
9d8/c203fb9e577d06a4

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

If this is part of the @Builder implementation 
(http://code.google.com/p/projectlombok/issues/detail?id=16), and the fluent 
setters are easier to implement than the @Builder, please release this one 
first.

Original issue reported on code.google.com by jmsa...@gmail.com on 23 Feb 2011 at 8:31

GoogleCodeExporter commented 9 years ago
(this should have been an enhancement, not a defect, sorry)

Original comment by jmsa...@gmail.com on 23 Feb 2011 at 8:32

GoogleCodeExporter commented 9 years ago
Darn -- I just noticed issue 15. This is a duplicate.

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

Original comment by jmsa...@gmail.com on 23 Feb 2011 at 8:35

GoogleCodeExporter commented 9 years ago

Original comment by r.spilker on 9 May 2011 at 7:31

GoogleCodeExporter commented 9 years ago

Original comment by reini...@gmail.com on 9 May 2011 at 8:58

GoogleCodeExporter commented 9 years ago
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.

Original comment by m...@thebishops.org on 17 Aug 2013 at 7:55

GoogleCodeExporter commented 9 years ago
@Accessors(fluent=true) should do the trick for you.

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

Original comment by askon...@gmail.com on 18 Aug 2013 at 9:41

GoogleCodeExporter commented 9 years ago
Or @Wither: http://projectlombok.org/features/experimental/Wither.html

Original comment by r.spilker on 21 Aug 2013 at 3:43