Oh, I'm sorry, I mentioned a JVM language other than Clojure! On Tue, Oct 12, 2010 at 8:59 PM, Casper Bang <[email protected]> wrote: > Wow, there's Scala again. Amazing how it somehow always sneaks in. As > to the topic at hand, I'd suggest submitting a request for > enhancement. The right people (Tulach etc.) can probably have this > done in a jiff with a check-box in the existing accessor wizard. > > On Oct 12, 9:46 pm, Ricky Clarkson <[email protected]> wrote: >> Scala's case classes plus named arguments really solve this well, >> particularly if the calling code can be Scala too. >> >> case class Node(x: Float, y: Float) >> >> On Tue, Oct 12, 2010 at 8:42 PM, B Smith-Mannschott >> >> >> >> >> >> >> >> <[email protected]> wrote: >> > OK, so we've established that neither Eclipse nor Lombok will do what >> > the OP needs. Are there any other alternatives? >> >> > I found myself needing something very similar only last week. In my >> > case, it was for a simple immutable value type (using Lombok's >> > lovely @Data) to which I wanted to add fluent builder style methods, >> > e.g.: >> >> > @Data >> > class Node { >> > private final float x; >> > private final float y; >> > // Lombok generates getX(), getY(), but not setX(), setY() >> > // because x, y are final. >> > // Lombok generates Node(float x, float y) constructor >> > // since x and y are final. >> > Node withX(float x) { >> > return new Node(x, y); >> > } >> > Node withY(float y) { >> > return new Node(x, y); >> > } >> > } >> >> > I ended up firing up emacs and defining a ad-hoc keyboard macro >> > to grind out the code for me. Yea! More boilerplate for the next >> > developer to wade through! huzzah! >> >> > How difficult would it be for someone inexperienced with Lombok's >> > internals to add something like this? >> >> > Stuff like this is why I'm glad there's more than just Java on the >> > JVM. For example, a Lisp (like Clojure) makes this kind of code >> > generation drudgery easy via its civilized [1] macro support. >> >> > [1] where uncivilized == the C preprocessor. >> >> > // Ben >> >> > On Tue, Oct 12, 2010 at 18:27, Reinier Zwitserloot <[email protected]> >> > wrote: >> >> project lombok can do this without cluttering up your code: >> >>http://projectlombok.org/(disclaimer: I'm a lombok developer). It >> >> works in both eclipse and netbeans (and the command line). >> >> >> Eclipse has built in support to generate these (in the source menu, >> >> "generate getters/setters"). I'm fairly sure netbeans has something >> >> similar, no plugins required. They do actually stick text in your >> >> source files that you then have to maintain, though, unlike Lombok. >> >> >> As far as I know none of these generate the 'return this' style >> >> setter, because that style of setter does not adhere to the bean >> >> standard. >> >> >> On Oct 12, 5:22 pm, Peter A Pilgrim <[email protected]> wrote: >> >>> Hi Everyone >> >> >>> May be even Tor can help. >> >> >>> Has anyone come across a name value pattern plugin for NetBeans or >> >>> Eclipse IDE? >> >>> Given a class like this: >> >> >>> class Node { >> >>> private float x; >> >>> private float y; >> >>> private float z; >> >> >>> } >> >> >>> The plugin generates the accessors and builder chain mutators >> >> >>> class Node { >> >>> private float x; >> >>> private float y; >> >>> private float z; >> >> >>> public float getX() { return x; } >> >>> public Node setX( float x ) { this.x = x; return this } >> >>> public float getY() { return x; } >> >>> public Node setY( float y ) { this.y = y; return this } >> >>> public float getZ() { return z; } >> >>> public Node setZ( float z ) { this.z = z; return this } >> >> >>> } >> >> >>> TIA >> >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> >> "The Java Posse" group. >> >> To post to this group, send email to [email protected]. >> >> To unsubscribe from this group, send email to >> >> [email protected]. >> >> For more options, visit this group >> >> athttp://groups.google.com/group/javaposse?hl=en. >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "The Java Posse" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group >> > athttp://groups.google.com/group/javaposse?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > >
-- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
