Use Advanced Search to search the entire archive.
Re: Remove "generic" multiply/divide operations from Quantity
- From: Werner Keil <
>
- To:
- Subject: Re: Remove "generic" multiply/divide operations from Quantity
- Date: Sun, 19 Oct 2014 20:25:11 +0200
Am 19.10.2014 20:15 schrieb "Martin Desruisseaux" <
>:
>
>
Le 20/10/14 02:52, Werner Keil a écrit :
>
>
> Without repeating myself, the cast to Energy fails miserably. I tried to
revive your Reflection based approach, but no operations like add(),...
works.
>
>
Point me to a test case showing the failure, and I will fix the code.
>
>
>
> Nice you mention Enum, it uses exactly the signature, Otavio suggested
since Java 5;-)
>
>
>
> http://docs.oracle.com/javase/6/docs/api/java/lang/Enum.html
>
>
Sight... Werner you still don't understand. The <T extends Enum<T>> T
valueOf(Class<T> enumType, String name) method signature establishes a
relationship between the argument and the return value. It said "The type
of the returned Enum is the one specified by the Class argument". This
relationship is real, and the Class object provides all needed information
for verifying that. By contrast, the UNITSOFMEASUREMENT-62 method signature
does not describe the real relationship between argument and return value,
and for this reason is unsafe.
>
In a Functional API like this any relationship would be Functional or
Semantic. I understand that better than most looking at it from a user's
point of view. Even Enum is more of a lower level API, though it can be
used for functional or business needs.
Without adding something like those JSR 308 checkers we never get and never
had true semantic compile time consistency on those <?> operations.
>
>
> About 200 or so cases in our implementations of SystemOfUnits alone,
that's not "cornerstone"
>
>
I will need to create a fork of the RI and fix it on my side, since I
want to see those cases myself.
>
The RI is fine, it would be better to focus on real problems, e.g.
Formatting;-)
Werner
>
Martin
>