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: Tue, 30 Sep 2014 15:28:45 -0700
+1 on Martin's input, I tried to elaborate a bit on why I think it does not
hurt.
Specialized implementations are allowed to do stuff like
public VolumeQuantity multiply(DistanceQuantity d1) {
AreaQuantity dq0 = convert(AreaUnit.sqmetre);
DistanceQuantity dq1 = d1.convert(DistanceUnit.m);
return new VolumeQuantity(dq0.units * dq1.units,
VolumeUnit.cumetre);
}
but I would not remove the general methods, see OSGi Measurement also
handled that (without generic compile time type-safety, but I tried it and
it throws RuntimeExceptions if you try to add Length to Mass or similar)
Martin, could you open a JIRA ticket for the suspect type issue on inverse,
please?
Werner
On Tue, Sep 30, 2014 at 3:02 PM, Martin Desruisseaux <
>
wrote:
>
Done, thanks for raising that.
>
>
I spotted an other issue while looking at the current Quantity interface,
>
but can not fill an issue because JIRA seems to be partially down. The
>
Quantity interface has the following method:
>
>
Quantity<Q> inverse()
>
>
>
The return type should be Quantity<?>, not Quantity<Q>, because the
>
inverse of a quantity is an other kind of quantity. For example the inverse
>
of a Time object is a Frequency object.
>
>
Martin
>
>
>
Le 30/09/14 22:52, Otávio Gonçalves de Santana a écrit :
>
>
Jean-Marie and Martin, can you take a look this issue, please.
>
>
https://java.net/jira/browse/UNITSOFMEASUREMENT-59
>
>
>