1

I'm using JSR-385 with the RI (Indriya). I have a Quantity q1 and defined as such:

QuantityFormat qf = ServiceProvider.current().getFormatService().getQuantityFormat();
Quantity q1 = qf.parse("10 J"); // Here strings are constants but they are coming from user input
                                  // The Unit of Measure can/will vary.

Now I want to understand what Quantity (i.e. what interface in javax.measure.quantity) q1 is measuring, if any.

I can retrieve Dimension but that is not the same thing:

Quantity q2. qf.parse("10 N*m");
System.stdout.println(q1.compareTo(q2)); // prints "0", but torque and energy are not the same thing

As additional "free rant", the API of Dimension.getBaseDimensions() are so inconsistent Instead of returning always a Map<Dimension, Integer> they just do so when the Dimension is not related to a base dimension, in which case it returns null (it could have more consistently still return the Map containing a single Map.Entry), except in the case of UnitDimension.NONE when it follows again the expected behavior and returns an empty Map.

zambotn
  • 735
  • 1
  • 7
  • 20

0 Answers0