Use Advanced Search to search the entire archive.
Re: On Quantity - Measurement relationship
- From: Werner Keil <
>
- To: "
" <
>
- Subject: Re: On Quantity - Measurement relationship
- Date: Sat, 1 Nov 2014 16:56:32 +0100
There were never any operations in JSR 275 on Quantity, thus it never
returned anything.
However, Dynamic Proxies are highly disregarded nowadays, e.g. CDI 2 tries
to get rid of it (while it was still used a lot in 1.0-1.1) and for ME
implementations it is totally unavailable, hence an API cannot return
generic types or interfaces like Q if those can never be instanciated on
ME.
ME is unlikely to support something even many SE/EE frameworks start to
abandon these days.
Assuming Quantity was a largely "anemic" or tagging interface with
Measurement extending it then the type safety via Q allowed concrete types
like SoandSoQuantity or SoAndSoAmount to implement Mass if it's
MassQuantity or -Amount. Then you could use the Mass interface, but as
operations would not work on that level, if you do multiply() or add()
you'd always get Quantity<Q> rather than Q.
Werner
On Sat, Nov 1, 2014 at 4:43 PM, Martin Desruisseaux <
>
wrote:
>
Le 02/11/14 00:31, Werner Keil a écrit :
>
>
These never worked, since we got a generic multiply operation on
>
Quantity and concrete classes like DoubleQuantity.
>
DoubleQuantity does not implement Mass, so returning Mass causes
>
ClassCastExceptions everwhere.
>
>
It does work with java.lang.reflect.Proxy. We did that in JSR-275, so you
>
have the proof that it works. Admittedly with a performance penalty, but we
>
are not forced to use proxy for every types.
>
>
>
Why, if Measurement was
>
>
>
> Measurement<Q extends Quantity<Q>> extends Quantity<Q> this worked
>
> perfectly fine.
>
>
>
You mean asType(Class<?>) works? Yes I know. But casting to (Mass) or
>
(Energy) is no longer available if Mass and Energy are not Measurement
>
subtypes. Or maybe you suggest to move also all the Mass, Energy, etc.
>
types as Measurement subtypes?
>
>
Martin
>
>