Use Advanced Search to search the entire archive.
[jsr363-experts] Re: Unit commensurability (again) - please I would like answers
- From: Werner Keil <
>
- To: "
" <
>
- Subject: [jsr363-experts] Re: Unit commensurability (again) - please I would like answers
- Date: Wed, 17 Dec 2014 11:20:03 +0100
Can you create a JIRA ticket (improvement) and paste relevant explanation
there, please?
On Wed, Dec 17, 2014 at 5:59 AM, Martin Desruisseaux <
>
wrote:
>
>
The specification said:
>
>
Two units *u1* and *u2* are compatible if and only if
>
u1.getDimension().equals(u2.getDimension()).
>
>
*First question:*
>
What is the expected result of the following code? Shall c be the
>
identity converter or shall the code throw an IncommensurableException?
>
If I interpret the specification literally, we would get an identity
>
converter (no exception thrown). Is it what we want?
>
>
Unit<Energy> energy = SI.JOULE;
>
Unit<Torque> torque = SI.NEWTON.multiply(SI.METRE).asType(Torque.class);
>
UnitConverter c = energy.getConverterToAny(torque);
>
>
*Second question:*
>
What is the expected result of the following code? Should the operation
>
succeed or throw a ClassCastException?
>
>
Quantity<Energy> energy = factory.create(1, SI.JOULE);
>
Quantity<Torque> torque = energy.asType(Torque.class);
>
>
My opinion is that above Quantity.asType(class) should throw an
>
exception even if the units are commensurable. Do we agree on that?
>
>
Martin
>
>