Package javax.measure.spi
Interface SystemOfUnitsService
-
public interface SystemOfUnitsService
This interface represents the service to obtain asystem of units.Common systems of units are "SI" (System International) or Metric system, "Imperial" (British), or "US" (US Customary).
- Since:
- 1.0
- Version:
- 1.8, April 3, 2023
- Author:
- Jean-Marie Dautelle, Werner Keil, Martin Desruisseaux
- See Also:
- Wikipedia: International System of Units
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Collection<SystemOfUnits>getAvailableSystemsOfUnits()Gets a list with available systems for thisSystemOfUnitsService.default <P extends Prefix>
java.util.Set<P>getPrefixes(java.lang.Class<P> prefixType)Returns aSetcontaining the values of a particularPrefixtype.SystemOfUnitsgetSystemOfUnits()Returns the defaultsystem of units.SystemOfUnitsgetSystemOfUnits(java.lang.String name)Returns the system of units having the specified name ornullif none is found.
-
-
-
Method Detail
-
getSystemOfUnits
SystemOfUnits getSystemOfUnits()
Returns the defaultsystem of units. Depending on the implementation this may be the International System of Units or another default system.- Returns:
- the default system of units.
-
getSystemOfUnits
SystemOfUnits getSystemOfUnits(java.lang.String name)
Returns the system of units having the specified name ornullif none is found.- Parameters:
name- the system of unit name.- Returns:
- the system of units for the given name.
-
getAvailableSystemsOfUnits
java.util.Collection<SystemOfUnits> getAvailableSystemsOfUnits()
Gets a list with available systems for thisSystemOfUnitsService.- Returns:
- list of available systems of units, never null.
-
getPrefixes
default <P extends Prefix> java.util.Set<P> getPrefixes(java.lang.Class<P> prefixType)
Returns aSetcontaining the values of a particularPrefixtype.This method may be used to iterate over certain prefixes as follows:
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, namelyfor(MetricPrefix mp : service.getPrefixes(MetricPrefix.class)) System.out.println(p);MetricPrefixandBinaryPrefix. Implementors shall override this method if they provide prefixes implemented in a different way.- Type Parameters:
P- compile-time value of theprefixTypeargument- Parameters:
prefixType- thePrefixtype- Returns:
- a set containing the constant values of this Prefix type, in the order they're declared
- Throws:
java.lang.ClassCastException- if the class is not compatible with the desired Prefix implementation or does not implement Prefix at all.- Since:
- 2.0
-
-