Top Description Methods
javax.measure.spi

public Interface SystemOfUnitsService

Imports
java.util.Collection, .EnumSet, .Set, javax.measure.Prefix

This interface represents the service to obtain a system of units.

Common systems of units are "SI" (System International) or Metric system, "Imperial" (British), or "US" (US Customary).

Authors
Jean-Marie Dautelle, Werner Keil, Martin Desruisseaux
Since
1.0
Version
1.8, April 3, 2023
See Also
Wikipedia: International System of Units

Method Summary

Modifier and TypeMethod and Description
public Collection<SystemOfUnits>

Returns:

list of available systems of units, never null.
getAvailableSystemsOfUnits
()

Gets a list with available systems for this SystemOfUnitsService.

public default <
compile-time value of the prefixType argument
P extends Prefix
>
Set<P>

Returns:

a set containing the constant values of this Prefix type, in the order they're declared
getPrefixes
(Class<P>
the Prefix type
prefixType
)

Returns a Set containing the values of a particular Prefix type.

public SystemOfUnits

Returns:

the default system of units.
getSystemOfUnits
()

Returns the default system of units.

public SystemOfUnits

Returns:

the system of units for the given name.
getSystemOfUnits
(String
the system of unit name.
name
)

Returns the system of units having the specified name or null if none is found.

Method Detail

getAvailableSystemsOfUnitsback to summary
public Collection<SystemOfUnits> getAvailableSystemsOfUnits()

Gets a list with available systems for this SystemOfUnitsService.

Returns:Collection<SystemOfUnits>

list of available systems of units, never null.

getPrefixesback to summary
public default <P extends Prefix> Set<P> getPrefixes(Class<P> prefixType)

Returns a Set containing the values of a particular Prefix type.

This method may be used to iterate over certain prefixes as follows:

for(MetricPrefix mp : service.getPrefixes(MetricPrefix.class))
       System.out.println(p);
The default implementation assumes that prefixes of the given type are implemented as an enumeration. This is the case of the two default prefix implementations provided in JSR 385, namely javax.measure.MetricPrefix and javax.measure.BinaryPrefix. Implementors shall override this method if they provide prefixes implemented in a different way.
Parameters
<P>
compile-time value of the prefixType argument
prefixType:Class<P>

the Prefix type

Returns:Set<P>

a set containing the constant values of this Prefix type, in the order they're declared

Annotations
@SuppressWarnings:unchecked, rawtypes
Exceptions
ClassCastException:
if the class is not compatible with the desired Prefix implementation or does not implement Prefix at all.
Since
2.0
getSystemOfUnitsback to summary
public SystemOfUnits getSystemOfUnits()

Returns the default system of units. Depending on the implementation this may be the International System of Units or another default system.

Returns:SystemOfUnits

the default system of units.

getSystemOfUnitsback to summary
public SystemOfUnits getSystemOfUnits(String name)

Returns the system of units having the specified name or null if none is found.

Parameters
name:String

the system of unit name.

Returns:SystemOfUnits

the system of units for the given name.