Is language support for collections is a coin feature ?
Reinier Zwitserloot
reinier at zwitserloot.com
Wed Sep 29 07:57:52 PDT 2010
Sure, consistency is important. I didn't post these examples as a bid for
'this is to be the definitive syntax', just trying to show that within the
confines of the current syntax rules, there are plenty of options. What's
needed is a keyword or some other facility to quickly _produce_ the builders
that are required to make it all work. The annotations system can more or
less do this (the builders are new source files), though some
standardization or at least shipping it with java itself wouldn't go amiss.
These are much simpler options than changing the syntax itself.
--Reinier Zwitserloot
On Wed, Sep 29, 2010 at 1:02 PM, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
> My intention was to focus on consistent syntax:
>
> Either use "=" or method invocations consistently.
>
> -Ulf
>
>
>
> Am 28.09.2010 23:55, schrieb Reinier Zwitserloot:
>
> Because arrays are obsolete. Also, in the example I showed, you're actually
> giving an AddressBuilder to .add(), not an Address. With methods, you could
> accept either. This trick doesn't work so well with arrays. Same story if
> generics are involved.
>
> --Reinier Zwitserloot
>
>
>
> On Sun, Sep 26, 2010 at 2:39 PM, Ulf Zibis <Ulf.Zibis at gmx.de> wrote:
>
>> Am 26.09.2010 05:51, schrieb Reinier Zwitserloot:
>>
>> Advocate of the devil mode:
>>>
>>> User user = new User()
>>> .firstName("Remi")
>>> .lastName("Forax")
>>> .addAddress().zipCode("30785").done()
>>> .address(new Address().zipCode("30785"));
>>>
>>
>> See also:
>> http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001180.html
>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6479372
>>
>>
>> User user = new UserBuilder() {{
>>> firstName = "Remi";
>>> lastName = "Forax";
>>> addresses.add(
>>> new AddressBuilder() {{
>>> zipCode = "30785";
>>> }},
>>> new AddressBuilder() {{
>>> zipCode = "67899";
>>> }});
>>> }}.build();
>>>
>>>
>> Why not? :
>>
>>
>> User user = new UserBuilder() {{
>> firstName = "Remi";
>> lastName = "Forax";
>> addresses = new Address[] {
>>
>> new AddressBuilder() {{
>> zipCode = "30785";
>> }},
>> new AddressBuilder() {{
>> zipCode = "67899";
>> }}
>> };
>> }}.build();
>>
>>
>> -Ulf
>>
>>
>
More information about the coin-dev
mailing list