Top Description Inners Fields Constructors Methods
tech.units.indriya

public abstract Class AbstractSystemOfUnits

extends Object
implements SystemOfUnits, Nameable
Class Inheritance
All Implemented Interfaces
tech.uom.lib.common.function.Nameable, javax.measure.spi.SystemOfUnits
Known Direct Subclasses
tech.units.indriya.unit.Units
Imports
tech.units.indriya.format.SimpleUnitFormat, .UnitStyle, tech.uom.lib.common.function.Nameable, javax.measure.Dimension, .Quantity, .Unit, javax.measure.spi.SystemOfUnits, java.util.*, java.util.logging.Level, java.util.logging.Logger, java.util.stream.Collectors

An abstract base class for unit systems.

Author
Werner Keil
Since
1.0
Version
2.3, November 23, 2024

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
AbstractSystemOfUnits.Helper

Static helper class.

Field Summary

Modifier and TypeField and Description
protected static final java.util.logging.Logger
protected final Map<Class<? extends Quantity<Q extends Quantity<Q>>>, Unit<Q extends Quantity<Q>>>
quantityToUnit

Holds the mapping quantity to unit.

protected final Set<Unit<?>>
units

Holds the units.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract String
public <Q extends Quantity<Q>> Unit<Q>
getUnit(Class<Q>
the quantity type.
quantityType
)

Implements javax.measure.spi.SystemOfUnits.getUnit.

Returns the default unit for the specified quantity or null if none is defined for the given quantity in this unit system.

public Unit<?>
getUnit(String
the string representation of a unit, not null.
string
)

Implements javax.measure.spi.SystemOfUnits.getUnit.

Returns a unit with the given string representation or null if none is found in this unit system.

public Unit<?>

Returns:

the unit with the given string representation.
getUnit
(String
the string representation of a unit, not null.
string
,
UnitStyle
the style of unit representation.
style
,
boolean
ignore the case or not?
ignoreCase
)

Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.

public Unit<?>

Returns:

the unit with the given string representation.
getUnit
(String
the string representation of a unit, not null.
string
,
UnitStyle
the style of unit representation.
style
)

Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.

public Set<Unit<?>>
getUnits()

Implements javax.measure.spi.SystemOfUnits.getUnits.

Returns a read only view over the units explicitly defined by this system.

public Set<? extends Unit<?>>
getUnits(Dimension
the dimension of the units to be returned.
dimension
)

Implements javax.measure.spi.SystemOfUnits.getUnits.

Returns the units defined in this system having the specified dimension (convenience method).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected static final java.util.logging.Logger logger
quantityToUnitback to summary
protected final Map<Class<? extends Quantity<Q extends Quantity<Q>>>, Unit<Q extends Quantity<Q>>> quantityToUnit

Holds the mapping quantity to unit.

Annotations
@SuppressWarnings:rawtypes
unitsback to summary
protected final Set<Unit<?>> units

Holds the units.

Constructor Detail

AbstractSystemOfUnitsback to summary
public AbstractSystemOfUnits()

Method Detail

getNameback to summary
public abstract String getName()

Redeclares javax.measure.spi.SystemOfUnits.getName, tech.uom.lib.common.function.Nameable.getName.

Returns:String

Doc from javax.measure.spi.SystemOfUnits.getName.

a name

getUnitback to summary
public <Q extends Quantity<Q>> Unit<Q> getUnit(Class<Q> quantityType)

Implements javax.measure.spi.SystemOfUnits.getUnit.

Doc from javax.measure.spi.SystemOfUnits.getUnit.

Returns the default unit for the specified quantity or null if none is defined for the given quantity in this unit system.

Parameters
<Q>
the compile-time quantity type.
quantityType:Class<Q>

the quantity type.

Returns:Unit<Q>

the unit for the specified quantity.

Annotations
@SuppressWarnings:unchecked
@Override
getUnitback to summary
public Unit<?> getUnit(String string)

Implements javax.measure.spi.SystemOfUnits.getUnit.

Doc from javax.measure.spi.SystemOfUnits.getUnit.

Returns a unit with the given string representation or null if none is found in this unit system.

Parameters
string:String

the string representation of a unit, not null.

Returns:Unit<?>

the unit with the given string representation.

Annotations
@Override
getUnitback to summary
public Unit<?> getUnit(String string, UnitStyle style, boolean ignoreCase)

Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.

Note

Use ignoreCase carefully, as it will find the FIRST unit for a particular string, e.g. the symbol of SECOND and SIEMENS would be the same without case, but the UPPERCASE letter sorted first.

Parameters
string:String

the string representation of a unit, not null.

style:UnitStyle

the style of unit representation.

ignoreCase:boolean

ignore the case or not?

Returns:Unit<?>

the unit with the given string representation.

Since
2.0
getUnitback to summary
public Unit<?> getUnit(String string, UnitStyle style)

Returns a unit with the given string representation in a particular style or null if none is found in this unit system and requested style.

Parameters
string:String

the string representation of a unit, not null.

style:UnitStyle

the style of unit representation.

Returns:Unit<?>

the unit with the given string representation.

Since
2.0
getUnitsback to summary
public Set<Unit<?>> getUnits()

Implements javax.measure.spi.SystemOfUnits.getUnits.

Doc from javax.measure.spi.SystemOfUnits.getUnits.

Returns a read only view over the units explicitly defined by this system. This include the base and derived units which are assigned a special name and symbol. This set does not include new units created by arithmetic or other operations.

Returns:Set<Unit<?>>

the defined collection of units.

Annotations
@Override
getUnitsback to summary
public Set<? extends Unit<?>> getUnits(Dimension dimension)

Implements javax.measure.spi.SystemOfUnits.getUnits.

Doc from javax.measure.spi.SystemOfUnits.getUnits.

Returns the units defined in this system having the specified dimension (convenience method).

Parameters
dimension:Dimension

the dimension of the units to be returned.

Returns:Set<? extends Unit<?>>

the collection of units of specified dimension.

Annotations
@Override
tech.units.indriya back to summary

protected Class AbstractSystemOfUnits.Helper

extends Object
Class Inheritance

Static helper class.
Since
1.0

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static <U extends Unit<?>> U

Returns:

unit.
addUnit
(Set<Unit<?>>
the collection to add to.
units
,
U
the unit being added.
unit
,
String
the name of the unit.
name
)

Adds a new named unit to a collection.

public static <U extends Unit<?>> U

Returns:

unit.
addUnit
(Set<Unit<?>>
the collection to add to.
units
,
U
the unit being added.
unit
,
String
the name of the unit.
name
,
String
the symbol of the unit.
symbol
)

Adds a new named unit to a collection.

public static <U extends Unit<?>> U

Returns:

unit.
addUnit
(Set<Unit<?>>
the set to add to.
units
,
U
the unit being added.
unit
,
final String
the name of the unit.
name
,
final String
the symbol of the unit.
symbol
,
UnitStyle
style of the unit.
style
)

Adds a new named unit to a set.

public static <U extends Unit<?>> U

Returns:

unit.
addUnit
(Set<Unit<?>>
the set to add to.
units
,
U
the unit being added.
unit
,
String
the text for the unit.
text
,
UnitStyle
style of the unit.
style
)

Adds a new labeled unit to a set.

pack-priv static Set<Unit<?>>
getUnitsOfDimension(final Set<Unit<?>> units, Dimension dimension)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Helperback to summary
protected Helper()

Method Detail

addUnitback to summary
public static <U extends Unit<?>> U addUnit(Set<Unit<?>> units, U unit, String name)

Adds a new named unit to a collection.

Parameters
units:Set<Unit<?>>

the collection to add to.

unit:U

the unit being added.

name:String

the name of the unit.

Returns:U

unit.

Since
1.0
addUnitback to summary
public static <U extends Unit<?>> U addUnit(Set<Unit<?>> units, U unit, String name, String symbol)

Adds a new named unit to a collection.

Parameters
units:Set<Unit<?>>

the collection to add to.

unit:U

the unit being added.

name:String

the name of the unit.

symbol:String

the symbol of the unit.

Returns:U

unit.

Since
1.0
addUnitback to summary
public static <U extends Unit<?>> U addUnit(Set<Unit<?>> units, U unit, final String name, final String symbol, UnitStyle style)

Adds a new named unit to a set.

Parameters
units:Set<Unit<?>>

the set to add to.

unit:U

the unit being added.

name:String

the name of the unit.

symbol:String

the symbol of the unit.

style:UnitStyle

style of the unit.

Returns:U

unit.

Annotations
@SuppressWarnings:unchecked
Since
1.0.1
addUnitback to summary
public static <U extends Unit<?>> U addUnit(Set<Unit<?>> units, U unit, String text, UnitStyle style)

Adds a new labeled unit to a set.

Parameters
units:Set<Unit<?>>

the set to add to.

unit:U

the unit being added.

text:String

the text for the unit.

style:UnitStyle

style of the unit.

Returns:U

unit.

Annotations
@SuppressWarnings:unchecked
Since
1.0.1
getUnitsOfDimensionback to summary
pack-priv static Set<Unit<?>> getUnitsOfDimension(final Set<Unit<?>> units, Dimension dimension)