Package tech.units.indriya.unit
Class AnnotatedUnit<Q extends javax.measure.Quantity<Q>>
- java.lang.Object
-
- tech.units.indriya.AbstractUnit<Q>
-
- tech.units.indriya.unit.AnnotatedUnit<Q>
-
- Type Parameters:
Q- The type of the quantity measured by this unit.
- All Implemented Interfaces:
Serializable,Comparable<javax.measure.Unit<Q>>,javax.measure.Unit<Q>,ComparableUnit<Q>,tech.uom.lib.common.function.Nameable,tech.uom.lib.common.function.PrefixOperator<Q>,tech.uom.lib.common.function.SymbolSupplier
public final class AnnotatedUnit<Q extends javax.measure.Quantity<Q>> extends AbstractUnit<Q>
This class represents an annotated unit.
Instances of this class are created through the
of(Unit, String)method.- Since:
- 1.0
- Version:
- 1.5, March 30, 2019
- Author:
- Jean-Marie Dautelle, Werner Keil
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractUnit
AbstractUnit.Equalizer
-
-
Field Summary
-
Fields inherited from class tech.units.indriya.AbstractUnit
name, ONE, SYMBOL_TO_UNIT
-
-
Constructor Summary
Constructors Constructor Description AnnotatedUnit(javax.measure.Unit<Q> actualUnit, String annotation)Creates an annotated unit equivalent to the specified unit.
-
Method Summary
Modifier and Type Method Description booleanequals(Object obj)javax.measure.Unit<Q>getActualUnit()Returns the actual unit of this annotated unit (never an annotated unit itself).StringgetAnnotation()Returns the annotation of this annotated unit.Map<? extends javax.measure.Unit<?>,Integer>getBaseUnits()javax.measure.DimensiongetDimension()StringgetSymbol()javax.measure.UnitConvertergetSystemConverter()Returns the converter from this unit to its unscaledSystem Unitunit.inthashCode()static <Q extends javax.measure.Quantity<Q>>
AnnotatedUnit<Q>of(javax.measure.Unit<Q> actualUnit, String annotation)Creates an annotated unit equivalent to the specified unit.javax.measure.Unit<Q>toSystemUnit()Returns the unscaledSIunit from which this unit is derived.-
Methods inherited from class tech.units.indriya.AbstractUnit
alternate, annotate, asType, compareTo, divide, divide, divide, divide, getActualType, getConverterTo, getConverterToAny, getName, getSystemUnit, internalGetConverterTo, inverse, isCompatible, isEquivalentTo, isSystemUnit, multiply, multiply, multiply, multiply, parse, pow, prefix, root, setName, setSymbol, shift, shift, toString, transform
-
-
-
-
Constructor Detail
-
AnnotatedUnit
public AnnotatedUnit(javax.measure.Unit<Q> actualUnit, String annotation)
Creates an annotated unit equivalent to the specified unit.- Parameters:
actualUnit- the unit to be annotated.annotation- the annotation.
-
-
Method Detail
-
getActualUnit
public javax.measure.Unit<Q> getActualUnit()
Returns the actual unit of this annotated unit (never an annotated unit itself).- Returns:
- the actual unit.
-
getAnnotation
public String getAnnotation()
Returns the annotation of this annotated unit.- Returns:
- the annotation.
-
getBaseUnits
public Map<? extends javax.measure.Unit<?>,Integer> getBaseUnits()
- Specified by:
getBaseUnitsin interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>- Specified by:
getBaseUnitsin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
toSystemUnit
public javax.measure.Unit<Q> toSystemUnit()
Description copied from class:AbstractUnitReturns the unscaledSIunit from which this unit is derived. The SI unit can be be used to identify a quantity given the unit. For example:static boolean isAngularVelocity(AbstractUnit> unit) { return unit.toSystemUnit().equals(RADIAN.divide(SECOND)); } assert(REVOLUTION.divide(MINUTE).isAngularVelocity()); // Returns true.- Specified by:
toSystemUnitin classAbstractUnit<Q extends javax.measure.Quantity<Q>>- Returns:
- the unscaled metric unit from which this unit is derived.
-
getDimension
public javax.measure.Dimension getDimension()
- Specified by:
getDimensionin interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>- Specified by:
getDimensionin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
getSystemConverter
public javax.measure.UnitConverter getSystemConverter()
Description copied from interface:ComparableUnitReturns the converter from this unit to its unscaledSystem Unitunit.- Returns:
getConverterTo(this.toSystemUnit())- See Also:
#toSystemUnit
-
hashCode
public int hashCode()
- Specified by:
hashCodein classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
equals
public boolean equals(Object obj)
- Specified by:
equalsin classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
of
public static <Q extends javax.measure.Quantity<Q>> AnnotatedUnit<Q> of(javax.measure.Unit<Q> actualUnit, String annotation)
Creates an annotated unit equivalent to the specified unit.- Parameters:
actualUnit- the unit to be annotated.annotation- the annotation.- Returns:
- the annotated unit.
-
-