Use Advanced Search to search the entire archive.
Re: Proposal
- From: Jean-Marie Dautelle <
>
- To:
- Subject: Re: Proposal
- Date: Sun, 2 Nov 2014 13:02:40 +0100
It should be noted that most users will deal with "double" (since the API
supports any kind of numbers).
I would expect something like:
public void wait(Time delay) {
double seconds = delay.doubleValue(SECOND);
}
class Parcel {
double kilograms;
Mass getWeight() { return Quantities.DOUBLE.massOf(kilograms,
KILOGRAM); }
...
}
We could also define QuantityFactory as:
interface QuantityFactory<Q extends Quantity<Q>, N extends Number> {
Q of(N value, Unit<Q>);
}
With Quantities (in RI being):
abstract class Quantities {
public static QuantityFactory<Mass, Double> MASS = ...;
public static QuantityFactory<Length, Double> LENGTH = ...;
...
}
Then :
class Parcel {
double kilograms;
Mass getWeight() { return Quantities.MASS.of(kilograms, KILOGRAM); }
...
}
On Sun, Nov 2, 2014 at 12:40 PM, Jean-Marie Dautelle
<
>
wrote:
>
> Do I'm understanding right?
>
>
Yes 100 %
>
>
On Sun, Nov 2, 2014 at 12:24 PM, Martin Desruisseaux <
>
>
>
wrote:
>
>
> Hello Jean-Marie
>
>
>
> To summarize, you are suggesting three things:
>
>
>
>
>
> 1. Remove the Measurement interface in order to avoid the conceptual
>
> problem with hierarchy.
>
> 2. Define the Quantity interface as a quantitative measurement (since
>
> it contains a value and a unit).
>
> 3. Overload the multiply and divide methods for type safety.
>
>
>
>
>
> Do I'm understanding right?
>
>
>
> Martin
>
>
>
>
>
>
>
--
>
It is not the strongest of the species that survives, nor the most
>
intelligent. It is the one that is most adaptable to change. - Darwin's
>
Origin of Species (digest)
>
--
It is not the strongest of the species that survives, nor the most
intelligent. It is the one that is most adaptable to change. - Darwin's
Origin of Species (digest)