Package tech.units.indriya.unit
Class BaseUnit<Q extends javax.measure.Quantity<Q>>
- java.lang.Object
-
- tech.units.indriya.AbstractUnit<Q>
-
- tech.units.indriya.unit.BaseUnit<Q>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<javax.measure.Unit<Q>>
,javax.measure.Unit<Q>
,ComparableUnit<Q>
public final class BaseUnit<Q extends javax.measure.Quantity<Q>> extends AbstractUnit<Q>
This class represents the building blocks on top of which all others physical units are created. Base units are always unscaled SI units.
When using the
standard model
, all seven SI base units are dimensionally independent.- Since:
- 1.0
- Version:
- 1.2, August 06, 2017
- See Also:
- Wikipedia: SI base unit, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractUnit
AbstractUnit.Equalizer
-
-
Field Summary
Fields Modifier and Type Field Description private javax.measure.Dimension
dimension
Holds the base unit dimension.private Q
quantityType
private static long
serialVersionUID
private java.lang.String
symbol
Holds the symbol.-
Fields inherited from class tech.units.indriya.AbstractUnit
name, ONE, SYMBOL_TO_UNIT
-
-
Constructor Summary
Constructors Constructor Description BaseUnit(java.lang.String symbol)
Creates a base unit having the specified symbol.BaseUnit(java.lang.String symbol, java.lang.String name)
Creates a base unit having the specified symbol and name.BaseUnit(java.lang.String symbol, javax.measure.Dimension dimension)
Creates a base unit having the specified symbol and dimension.BaseUnit(java.lang.String symbol, javax.measure.Dimension dimension, Q quant)
Creates a base unit having the specified symbol and dimension.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.util.Map<? extends AbstractUnit<Q>,java.lang.Integer>
getBaseUnits()
javax.measure.Dimension
getDimension()
protected Q
getQuantityType()
java.lang.String
getSymbol()
javax.measure.UnitConverter
getSystemConverter()
Returns the converter from this unit to its unscaledSystem Unit
unit.int
hashCode()
javax.measure.Unit<Q>
toSystemUnit()
Returns the unscaledSI
unit from which this unit is derived.-
Methods inherited from class tech.units.indriya.AbstractUnit
alternate, annotate, asType, compareTo, divide, divide, divide, getActualType, getConverterTo, getConverterToAny, getName, getSystemUnit, inverse, isCompatible, isEquivalentOf, isSystemUnit, multiply, multiply, multiply, parse, pow, prefix, root, setName, setSymbol, shift, toString, transform
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
symbol
private final java.lang.String symbol
Holds the symbol.
-
dimension
private final javax.measure.Dimension dimension
Holds the base unit dimension.
-
-
Constructor Detail
-
BaseUnit
public BaseUnit(java.lang.String symbol, javax.measure.Dimension dimension, Q quant)
Creates a base unit having the specified symbol and dimension.- Parameters:
symbol
- the symbol of this base unit.
-
BaseUnit
public BaseUnit(java.lang.String symbol, javax.measure.Dimension dimension)
Creates a base unit having the specified symbol and dimension.- Parameters:
symbol
- the symbol of this base unit.
-
BaseUnit
public BaseUnit(java.lang.String symbol)
Creates a base unit having the specified symbol.- Parameters:
symbol
- the symbol of this base unit.
-
BaseUnit
public BaseUnit(java.lang.String symbol, java.lang.String name)
Creates a base unit having the specified symbol and name.- Parameters:
symbol
- the symbol of this base unit.name
- the name of this base unit.- Throws:
java.lang.IllegalArgumentException
- if the specified symbol is associated to a different unit.
-
-
Method Detail
-
getQuantityType
protected Q getQuantityType()
-
getSymbol
public java.lang.String getSymbol()
-
toSystemUnit
public javax.measure.Unit<Q> toSystemUnit()
Description copied from class:AbstractUnit
Returns the unscaledSI
unit 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:
toSystemUnit
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
- Returns:
- the unscaled metric unit from which this unit is derived.
-
getSystemConverter
public javax.measure.UnitConverter getSystemConverter() throws java.lang.UnsupportedOperationException
Description copied from class:AbstractUnit
Returns the converter from this unit to its unscaledSystem Unit
unit.- Specified by:
getSystemConverter
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
- Returns:
getConverterTo(this.toSystemUnit())
- Throws:
java.lang.UnsupportedOperationException
- See Also:
AbstractUnit.toSystemUnit()
-
getDimension
public javax.measure.Dimension getDimension()
- Specified by:
getDimension
in interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>
- Specified by:
getDimension
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
equals
public final boolean equals(java.lang.Object obj)
- Specified by:
equals
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
hashCode
public final int hashCode()
- Specified by:
hashCode
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
getBaseUnits
public java.util.Map<? extends AbstractUnit<Q>,java.lang.Integer> getBaseUnits()
- Specified by:
getBaseUnits
in interfacejavax.measure.Unit<Q extends javax.measure.Quantity<Q>>
- Specified by:
getBaseUnits
in classAbstractUnit<Q extends javax.measure.Quantity<Q>>
-
-