Coder Social home page Coder Social logo

Setters return this about lombok HOT 6 CLOSED

lombokissues avatar lombokissues commented on September 18, 2024
Setters return this

from lombok.

Comments (6)

lombokissues avatar lombokissues commented on September 18, 2024

๐Ÿ‘ค facundo.m.viale ย  ๐Ÿ•— Aug 04, 2009 at 12:08 UTC

It would be useful for make chained invocation if the setters generated by
Lambok return the instance of the object.

Ej.

class Factory {
Factory setSomething(Something something) { ... return this; }
Factory setOther(Other other) { ... return this; }
Thing result() { ... }
}

Thing thing = new Factory()
.setSomething(something)
.setOther(other)
.result();

from lombok.

lombokissues avatar lombokissues commented on September 18, 2024

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 05, 2009 at 14:14 UTC

That would be the builder pattern. As unfortunate as it is, the understanding of a 'setter' in the greater java
community is a method that returns void.

We will add the Builder pattern at some point, though. That will help with chaining needs.

Adding a 'returnThis=true' kind of parameter to @ Setter also seems a bit unfortunate, as we'd have to
duplicate it to @ Data lest people are forced to add a tonne of @ Setter annotations. And yet, that feels like a
path that leads to 50 options on @ Data which is something we're trying to avoid - Hence, builder pattern.

I did make an issue for adding a Builder for you, though :)

from lombok.

lombokissues avatar lombokissues commented on September 18, 2024

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Aug 05, 2009 at 14:14 UTC

Duplicate of issue #89

from lombok.

lombokissues avatar lombokissues commented on September 18, 2024

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Oct 16, 2009 at 08:48 UTC

from lombok.

lombokissues avatar lombokissues commented on September 18, 2024

๐Ÿ‘ค reinierz ย  ๐Ÿ•— May 09, 2011 at 20:58 UTC

Issue #270 has been merged into this issue.

from lombok.

lombokissues avatar lombokissues commented on September 18, 2024

End of migration

from lombok.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.