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:
Serializable, 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:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • symbol

      private final String symbol
      Holds the symbol.
    • dimension

      private final javax.measure.Dimension dimension
      Holds the base unit dimension.
    • quantityType

      private Q extends javax.measure.Quantity<Q> quantityType
  • Constructor Details

    • BaseUnit

      public BaseUnit(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(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(String symbol)
      Creates a base unit having the specified symbol.
      Parameters:
      symbol - the symbol of this base unit.
    • BaseUnit

      public BaseUnit(String symbol, 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:
      IllegalArgumentException - if the specified symbol is associated to a different unit.
  • Method Details

    • getQuantityType

      protected Q getQuantityType()
    • getSymbol

      public String getSymbol()
      Specified by:
      getSymbol in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
      Overrides:
      getSymbol in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
    • toSystemUnit

      public javax.measure.Unit<Q> toSystemUnit()
      Description copied from class: AbstractUnit
      Returns the unscaled SI 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 class AbstractUnit<Q extends javax.measure.Quantity<Q>>
      Returns:
      the unscaled metric unit from which this unit is derived.
    • getSystemConverter

      public javax.measure.UnitConverter getSystemConverter() throws UnsupportedOperationException
      Description copied from class: AbstractUnit
      Returns the converter from this unit to its unscaled System Unit unit.
      Specified by:
      getSystemConverter in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
      Returns:
      getConverterTo(this.toSystemUnit())
      Throws:
      UnsupportedOperationException
      See Also:
    • getDimension

      public javax.measure.Dimension getDimension()
      Specified by:
      getDimension in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
      Specified by:
      getDimension in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
    • equals

      public final boolean equals(Object obj)
      Specified by:
      equals in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
    • hashCode

      public final int hashCode()
      Specified by:
      hashCode in class AbstractUnit<Q extends javax.measure.Quantity<Q>>
    • getBaseUnits

      public Map<? extends AbstractUnit<Q>,Integer> getBaseUnits()
      Specified by:
      getBaseUnits in interface javax.measure.Unit<Q extends javax.measure.Quantity<Q>>
      Specified by:
      getBaseUnits in class AbstractUnit<Q extends javax.measure.Quantity<Q>>