Use Advanced Search to search the entire archive.
Re: Remove "generic" multiply/divide operations from Quantity
- From: Martin Desruisseaux <
>
- To:
- Subject: Re: Remove "generic" multiply/divide operations from Quantity
- Date: Mon, 20 Oct 2014 01:31:00 +0900
- Organization: Geomatys
Thanks Jean-Marie. I fully share your view.
In my understanding, the JDK8 issues are mostly corner cases with
wildcard bounds because of compiler changes. But I don't think that any
of them have an impact on public API, because 1) they are corner cases,
and 2) there is no change in semantic or syntax of parameter types
declaration (only a simplification in their use with the diamond
operator, sometime with side-effects).
Martin
Le 20/10/14 01:18, Jean-Marie Dautelle a écrit :
>
Hello All,
>
>
Unit<?> is better than Unit without parameterized type. Also the
>
second issues warnings about the use of raw types.
>
Unit<?> makes a lot of sense in many cases, for example when we don't
>
know the unit type as: Unit<?> parseUnit(CharSequence)
>
The method Unit<Q> asType(Class<Q extends Quantity>) allows for proper
>
casting*with* runtime checking being performed. In other words you can
>
safely write:
>
Unit<Velocity> km_per_hour =
>
KILO(METER).divide(HOUR).asType(Velocity.class); // Safe.
>
Unit<Velocity> km_per_hour =
>
KILO(METER).times(HOUR).asType(Velocity.class); // Throws runtime error.
>
Unit<?> km_per_hour = KILO(METER).times(HOUR); // If I don't care
>
about unit types.
>
>
I don't understand the issue with JDK8 since all of the above works
>
well with JDK1.5+
>
Cheers,
>
JM