Skip to main content

[jsr363-experts] Re: Quantity.doubleValue(...) ?

  • From: Werner Keil < >
  • To: " " < >
  • Subject: [jsr363-experts] Re: Quantity.doubleValue(...) ?
  • Date: Mon, 15 Dec 2014 12:14:53 +0100

I recall, especially doubleValue() was found of no real value since you get
it directly via the Number of getValue().

The API must not use any of the new Java SE 8 stuff like Optional (in fact,
for a case like Range in uom-se it turned out to be flawed and useless, so
the range currently has to return null if there's no upper or lower
bound;-) so should there be a case where getValue() of a Quantity would be
null, what should a parallel doubleValue() then return?;-O
Or would we throw an exception?

Similar with doubleValue(Unit) this is just a convenience method for
to(Unit).getValue().doubleValue().
And should anything other than the obvious unit argument be null, then we
have the same issue here.
There are maybe just one or two concrete classes like
https://github.com/unitsofmeasurement/unit-ri/blob/master/src/main/java/tec/units/ri/quantity/DoubleQuantity.java
where doubleValue() directly based on the double member variable could help.

You'll notice, many of the low level methods went into
https://github.com/unitsofmeasurement/unit-ri/blob/master/src/main/java/tec/units/ri/AbstractQuantity.java
(I am not sure, why one of them is public, either it's used from another RI
package or it is a mistake) so the concrete and final (value like) classes
that benefit most like DoubleQuantity may override them as public while
others don't (where it rarely makes sense)

It may clutter the API, see JSR-275, but if there is one or another method
we really feel like adding through the next stages, that can evolve.

Werner

On Mon, Dec 15, 2014 at 5:26 AM, Martin Desruisseaux <
>
 wrote:
>
>  The specification contains a discussion about the following Quantity
> methods, which existed in JSR-275:
>
>    - double doubleValue();
>     - double doubleValue(Unit<Q> unit);
>
> Those methods do not exist in current JSR-363 Quantity interface. I do
> not remember what was the rational for removing them. Is there plan to
> re-introduce them, or shall we remove the discussion about those methods
> from the spec.?
>
>     Martin
>
>


[jsr363-experts] Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Werner Keil 12/15/2014

[jsr363-experts] Re: Quantity.doubleValue(...) ?

Martin Desruisseaux 12/15/2014
 
 
Close
loading
Please Confirm
Close