You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Ben Weidig <be...@netzgut.net> on 2020/10/16 08:01:07 UTC

Java Time API / JSR310 Type Coercers

Hi,

it would be great to see the Java Time API better integrated into Tapestry,
so I've started adding type coercers.

As with my JSON improvements, I've prepared a short proposal to highlight
the intentions and ramifications better. It's included in the ticket, which
also already has a patch:

Proposal: https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3

Ticket: https://issues.apache.org/jira/browse/TAP5-2645

Compare:
https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310

I've excluded the more "unusual" types in java.time.chrono, like
JapaneseDate etc.
But if you think they should be included as well, I could create an
additional patch.

Feedback is always welcome.

Cheers
Ben

-- 

Netzgut GmbH

Re: Java Time API / JSR310 Type Coercers

Posted by "Christopher Dodunski (Tapestry)" <Ch...@christopher.net.nz>.
Hi Ben,

I too predominantly use LocalDateTime in my web applications nowadays, 
and any improvements in Tapestry to facilitate this are very welcome.

With regards,

Chris Dodunski.


On 2020-10-20 02:45, David Taylor wrote:
> Hi Ben,
> 
> A nice addition. We use LocalDateTime and ZonedDateTime in many of our
> applications and will make good use of your new type coercers.
> 
> Best regards
> David
> emailsig
> On 10/16/2020 4:01 AM, Ben Weidig wrote:
>> Hi,
>> 
>> it would be great to see the Java Time API better integrated into 
>> Tapestry,
>> so I've started adding type coercers.
>> 
>> As with my JSON improvements, I've prepared a short proposal to 
>> highlight
>> the intentions and ramifications better. It's included in the ticket, 
>> which
>> also already has a patch:
>> 
>> Proposal: 
>> https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
>> 
>> Ticket: https://issues.apache.org/jira/browse/TAP5-2645
>> 
>> Compare:
>> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310
>> 
>> I've excluded the more "unusual" types in java.time.chrono, like
>> JapaneseDate etc.
>> But if you think they should be included as well, I could create an
>> additional patch.
>> 
>> Feedback is always welcome.
>> 
>> Cheers
>> Ben
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: Java Time API / JSR310 Type Coercers

Posted by David Taylor <da...@extensiatech.com>.
Hi Ben,

A nice addition. We use LocalDateTime and ZonedDateTime in many of our 
applications and will make good use of your new type coercers.

Best regards
David
emailsig
On 10/16/2020 4:01 AM, Ben Weidig wrote:
> Hi,
>
> it would be great to see the Java Time API better integrated into Tapestry,
> so I've started adding type coercers.
>
> As with my JSON improvements, I've prepared a short proposal to highlight
> the intentions and ramifications better. It's included in the ticket, which
> also already has a patch:
>
> Proposal: https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
>
> Ticket: https://issues.apache.org/jira/browse/TAP5-2645
>
> Compare:
> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310
>
> I've excluded the more "unusual" types in java.time.chrono, like
> JapaneseDate etc.
> But if you think they should be included as well, I could create an
> additional patch.
>
> Feedback is always welcome.
>
> Cheers
> Ben
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Re: Java Time API / JSR310 Type Coercers

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hello, Dmitry and Ben!

I'm sorry for being late for this discussion.

What if we add a configuration symbol to define whether the Long to class
coercions use nanos or millis and add the appropriate coercions?

Meanwhile, I'm planning to merge this pull request into master while
commenting out the contributions of Long coercions.

On Wed, Oct 21, 2020 at 11:35 AM Ben Weidig <be...@netzgut.net> wrote:

> Hi Dmitry,
>
> my reasoning was higher precision because the types are based on nanos
> instead of millis like java.util.Date, but your concerns are valid.
>
> Automatic type coercer resolution can be problematic, that's why I needed
> to add additional ones to ensure the correct types.
>
> IIRC self-defined coercions will be applied after the Tapestry coercers and
> will override them, not resulting in a crash (or warning).
>
> But using a symbol might be a simple solution for easier migrations.
>
> Thanks for the feedback!
> I'll gladly implement any solution that is acceptable for Tapestry.
>
> Cheers
> Ben
>
> On Wed, Oct 21, 2020 at 4:17 PM Dmitry Gusev <dm...@gmail.com>
> wrote:
>
> > Hi,
> >
> > There may be compatibility issues as the new coercions use the type
> `Long`
> > as intermediate value.
> >
> > I.e. Long -> LocalDate -- it currently treats long as nanos, but what if
> > Long is in milliseconds?
> >
> > Same with Duration (millis) and Instant (millis).
> >
> > If we apply these coercions unconditionally we may break existing
> > applications who have coercions defined in their own modules.
> >
> > For Strings it's probably fine as every type uses its own format, so I'd
> > suggest we remove Lond from the list of contributions.
> >
> > And maybe add the new conversions conditionally: it's fine to have them
> > enabled by default, but we should at least provide a symbol to disable
> > them?
> >
> >
> > On Wed, Oct 21, 2020 at 3:00 PM Thiago H. de Paula Figueiredo <
> > thiagohp@gmail.com> wrote:
> >
> > > On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <be...@netzgut.net> wrote:
> > >
> > > > Hi,
> > > >
> > >
> > > Hello!
> > >
> > >
> > > > it would be great to see the Java Time API better integrated into
> > > Tapestry,
> > > > so I've started adding type coercers.
> > > >
> > > > As with my JSON improvements, I've prepared a short proposal to
> > highlight
> > > > the intentions and ramifications better. It's included in the ticket,
> > > which
> > > > also already has a patch:
> > > >
> > > > Proposal:
> > > > https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
> > > >
> > > > Ticket: https://issues.apache.org/jira/browse/TAP5-2645
> > > >
> > > > Compare:
> > > >
> > > >
> > >
> >
> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310
> > >
> > >
> > > This is awesome! Thank you very much again for another great pull
> > request!
> > > If you agree, I shall merge it into master this week.
> > >
> > >
> > > >
> > > >
> > > > I've excluded the more "unusual" types in java.time.chrono, like
> > > > JapaneseDate etc.
> > > > But if you think they should be included as well, I could create an
> > > > additional patch.
> > > >
> > > > Feedback is always welcome.
> > > >
> > > > Cheers
> > > > Ben
> > > >
> > > > --
> > > >
> > > > Netzgut GmbH
> > > >
> > >
> > >
> > > --
> > > Thiago
> > >
> >
> >
> > --
> > Dmitry Gusev
> >
> > AnjLab Team
> > http://anjlab.com
> >
>
>
> --
>
> Netzgut GmbH
>


-- 
Thiago

Re: Java Time API / JSR310 Type Coercers

Posted by Ben Weidig <be...@netzgut.net>.
Hi Dmitry,

my reasoning was higher precision because the types are based on nanos
instead of millis like java.util.Date, but your concerns are valid.

Automatic type coercer resolution can be problematic, that's why I needed
to add additional ones to ensure the correct types.

IIRC self-defined coercions will be applied after the Tapestry coercers and
will override them, not resulting in a crash (or warning).

But using a symbol might be a simple solution for easier migrations.

Thanks for the feedback!
I'll gladly implement any solution that is acceptable for Tapestry.

Cheers
Ben

On Wed, Oct 21, 2020 at 4:17 PM Dmitry Gusev <dm...@gmail.com> wrote:

> Hi,
>
> There may be compatibility issues as the new coercions use the type `Long`
> as intermediate value.
>
> I.e. Long -> LocalDate -- it currently treats long as nanos, but what if
> Long is in milliseconds?
>
> Same with Duration (millis) and Instant (millis).
>
> If we apply these coercions unconditionally we may break existing
> applications who have coercions defined in their own modules.
>
> For Strings it's probably fine as every type uses its own format, so I'd
> suggest we remove Lond from the list of contributions.
>
> And maybe add the new conversions conditionally: it's fine to have them
> enabled by default, but we should at least provide a symbol to disable
> them?
>
>
> On Wed, Oct 21, 2020 at 3:00 PM Thiago H. de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
> > On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <be...@netzgut.net> wrote:
> >
> > > Hi,
> > >
> >
> > Hello!
> >
> >
> > > it would be great to see the Java Time API better integrated into
> > Tapestry,
> > > so I've started adding type coercers.
> > >
> > > As with my JSON improvements, I've prepared a short proposal to
> highlight
> > > the intentions and ramifications better. It's included in the ticket,
> > which
> > > also already has a patch:
> > >
> > > Proposal:
> > > https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
> > >
> > > Ticket: https://issues.apache.org/jira/browse/TAP5-2645
> > >
> > > Compare:
> > >
> > >
> >
> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310
> >
> >
> > This is awesome! Thank you very much again for another great pull
> request!
> > If you agree, I shall merge it into master this week.
> >
> >
> > >
> > >
> > > I've excluded the more "unusual" types in java.time.chrono, like
> > > JapaneseDate etc.
> > > But if you think they should be included as well, I could create an
> > > additional patch.
> > >
> > > Feedback is always welcome.
> > >
> > > Cheers
> > > Ben
> > >
> > > --
> > >
> > > Netzgut GmbH
> > >
> >
> >
> > --
> > Thiago
> >
>
>
> --
> Dmitry Gusev
>
> AnjLab Team
> http://anjlab.com
>


-- 

Netzgut GmbH

Re: Java Time API / JSR310 Type Coercers

Posted by Dmitry Gusev <dm...@gmail.com>.
Hi,

There may be compatibility issues as the new coercions use the type `Long`
as intermediate value.

I.e. Long -> LocalDate -- it currently treats long as nanos, but what if
Long is in milliseconds?

Same with Duration (millis) and Instant (millis).

If we apply these coercions unconditionally we may break existing
applications who have coercions defined in their own modules.

For Strings it's probably fine as every type uses its own format, so I'd
suggest we remove Lond from the list of contributions.

And maybe add the new conversions conditionally: it's fine to have them
enabled by default, but we should at least provide a symbol to disable them?


On Wed, Oct 21, 2020 at 3:00 PM Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <be...@netzgut.net> wrote:
>
> > Hi,
> >
>
> Hello!
>
>
> > it would be great to see the Java Time API better integrated into
> Tapestry,
> > so I've started adding type coercers.
> >
> > As with my JSON improvements, I've prepared a short proposal to highlight
> > the intentions and ramifications better. It's included in the ticket,
> which
> > also already has a patch:
> >
> > Proposal:
> > https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
> >
> > Ticket: https://issues.apache.org/jira/browse/TAP5-2645
> >
> > Compare:
> >
> >
> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310
>
>
> This is awesome! Thank you very much again for another great pull request!
> If you agree, I shall merge it into master this week.
>
>
> >
> >
> > I've excluded the more "unusual" types in java.time.chrono, like
> > JapaneseDate etc.
> > But if you think they should be included as well, I could create an
> > additional patch.
> >
> > Feedback is always welcome.
> >
> > Cheers
> > Ben
> >
> > --
> >
> > Netzgut GmbH
> >
>
>
> --
> Thiago
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Re: Java Time API / JSR310 Type Coercers

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <be...@netzgut.net> wrote:

> Hi,
>

Hello!


> it would be great to see the Java Time API better integrated into Tapestry,
> so I've started adding type coercers.
>
> As with my JSON improvements, I've prepared a short proposal to highlight
> the intentions and ramifications better. It's included in the ticket, which
> also already has a patch:
>
> Proposal:
> https://gist.github.com/benweidig/e0e7c9a26f3805e610c4511a0a15b9e3
>
> Ticket: https://issues.apache.org/jira/browse/TAP5-2645
>
> Compare:
>
> https://github.com/apache/tapestry-5/compare/master...benweidig:typecoercer-jsr310


This is awesome! Thank you very much again for another great pull request!
If you agree, I shall merge it into master this week.


>
>
> I've excluded the more "unusual" types in java.time.chrono, like
> JapaneseDate etc.
> But if you think they should be included as well, I could create an
> additional patch.
>
> Feedback is always welcome.
>
> Cheers
> Ben
>
> --
>
> Netzgut GmbH
>


-- 
Thiago