unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
118 stars 40 forks source link

Unit names almost always null #271

Closed richard-melvin closed 4 years ago

richard-melvin commented 4 years ago

JSR 385 – Version 2.0 states:

Some derived units get a special name and symbol for convenience. For example the SI unit of power (m²∙kg∙s-³) is named watt and is represented by the symbol W. Other derived units with special names include hertz, newton and volt.

The javax.measure.Unit interface has a method getName documented as:

Returns the name (if any) of this unit. This method returns null if this unit has no specific name associated with it.

In tech.units.indriya.unit.Units, almost all the sample units are created without names, for example:

public static final Unit<Power> WATT = addUnit(new AlternateUnit<Power>(JOULE.divide(SECOND), "W"), Power.class);

SoWATT.getName() returns null.

Surely in all cases where a named constant is used to identify a unit within a system of measures, as opposed to a unit being derived from a calculation, that means there is a name associated with that unit? And so that name should be returned.

Of course, naming a unit differently should not prevent it being equivalent to a differently-named unit.

Note that the same seems to be true for all current UOM systems based on Indriya.