That's true, but really the builder pattern is more of a common
workaround for the lack of named parameters, than a solution.  I'm not
advocating Scala here, just pointing at a feature as being worth
copying the hell out of.

On Tue, Oct 12, 2010 at 9:07 PM, Alexey Zinger <[email protected]> wrote:
> My understanding is that Scala case classes with named parameters do not
> produce a builder pattern.  Yes, they'll make it easy to construct an object
> within Scala, but this doesn't address the original problem, which is the
> need for a builder-like API so any JVM language could invoke it as such.
>
> Alexey
>
>
> ________________________________
> From: Ricky Clarkson <[email protected]>
> To: [email protected]
> Sent: Tue, October 12, 2010 3:46:54 PM
> Subject: Re: [The Java Posse] Re: Name Value Parameter Pattern Plugin for
> IDE
>
> 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 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.
>>
>>
>
> --
> 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.
>

-- 
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.

Reply via email to