Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [es-dev] Annotation literals added

Arjan,

looks good, except the of() method for creating a builder seems highly unusual and a little unintuitive.
Any place where CDI 2 or other Java EE JSRs called this exactly the same way?

JSON-P has builders that are called in a vaguely similar way, but:
 JsonArray value = factory.createArrayBuilder()
     .add(factory.createObjectBuilder()
         .add("type", "home")
         .add("number", "212 555-1234"))
     .add(factory.createObjectBuilder()
         .add("type", "fax")
         .add("number", "646 555-4567"))
     .build();
I'm not biased towards 
  .cookieMaxAgeSeconds(100)
as opposed to 
  .withCookieMaxAgeSeconds(100)
or
  .setCookieMaxAgeSeconds(100)   
or 
  .addCookieMaxAgeSeconds(100) 
all 3 used by several kinds of builders one way or another, but wouldn't   

RememberMe literal = RememberMe.Literal.builder()
                                       .cookieMaxAgeSeconds(100)
                                       .cookieSecureOnly(false)
                                       .cookieHttpOnly(false)
                                       .build();
or something similar be better?

As the method does not return Literal itself, but the LiteralBuilder. And look at Optional and all other cases I know, of(), valueOf() or instanceOf() always return the exact class they're applied on, not a builder.

Werner




On Wed, Jul 4, 2018 at 9:16 PM, arjan tijms <arjan.tijms@xxxxxxxxx> wrote:
Hi,

As a small API enhancement, I just added annotation literals modelled after CDI 2's annotation literals. 


Examples can be see via the unit test:


E.g.

RememberMe literal = RememberMe.Literal.of()
                                       .cookieMaxAgeSeconds(100)
                                       .cookieSecureOnly(false)
                                       .cookieHttpOnly(false)
                                       .build();

Kind regards,
Arjan



_______________________________________________
es-dev mailing list
es-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/es-dev



Back to the top