juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Bognar <james.bog...@salesforce.com>
Subject Re: Adding builder classes for serializers and parsers.
Date Fri, 03 Mar 2017 19:02:47 GMT
> Would the builder be able to take a parameter? So to clone the serializer
s but change the UseWhitespace setting:

Yea...I can include that.

You'll also be able to specify a subclass in the build method...
JsonSerializer n = new JsonSerializerBuilder().
useWhitespace(false).build(JsonSerializer.Simple.class);

On Fri, Mar 3, 2017 at 1:20 PM, Craig Russell <craig.russell@oracle.com>
wrote:

> From left field…
>
> > On Mar 3, 2017, at 5:14 AM, James Bognar <jamesbognar@apache.org> wrote:
> >
> > Hi all,
> >
> > I'm thinking about changing the way serializers and parsers are
> constructed
> > by creating builder classes.  I wanted to run it by the team first
> though.
> >
> > Creating a custom serializer would look like this...
> >
> > JsonSerializer s = new
> > JsonSerializerBuilder().useWhitespace(true).trimNulls(true).build();
>
> I like this pattern. I’m not a huge fan of setXXX when xxx is a perfectly
> good understandable concept
>
> > ...instead of...
> > JsonSerializer s = new
> > JsonSerializer().setUseWhitespace(true).setTrimNulls(true).lock();
> >
> > With this approach I can make the fields final and eliminate the
> read-write
> > locks from the classes.
> >
> > The DEFAULT serializers and parsers are not going away.  You won't be
> able
> > to clone and modify them anymore though.
> >
> > Any thoughts?
>
> Would the builder be able to take a parameter? So to clone the serializer
> s but change the UseWhitespace setting:
>
> JsonSerializer n = new
> JsonSerializerBuilder(s).useWhitespace(false).build();
>
> Craig
>
> Craig L Russell
> clr@apache.org
>
>
>


-- 
James Bognar

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message