Java Time API / JSR310 Type Coercers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Java Time API / JSR310 Type Coercers

Ben Weidig
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
Reply | Threaded
Open this post in threaded view
|

Re: Java Time API / JSR310 Type Coercers

David Taylor
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Java Time API / JSR310 Type Coercers

Christopher
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: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away." - Antoine de Saint-Exupéry.
Reply | Threaded
Open this post in threaded view
|

Re: Java Time API / JSR310 Type Coercers

Thiago H de Paula Figueiredo
In reply to this post by Ben Weidig
On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Java Time API / JSR310 Type Coercers

Dmitry Gusev
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 <
[hidden email]> wrote:

> On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Java Time API / JSR310 Type Coercers

Ben Weidig
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 <[hidden email]> 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 <
> [hidden email]> wrote:
>
> > On Fri, Oct 16, 2020 at 5:01 AM Ben Weidig <[hidden email]> 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