Class DefaultQuantityFactory<Q extends javax.measure.Quantity<Q>>

java.lang.Object
tech.units.indriya.quantity.DefaultQuantityFactory<Q>
Type Parameters:
Q - The type of the quantity.
All Implemented Interfaces:
javax.measure.spi.QuantityFactory<Q>

public class DefaultQuantityFactory<Q extends javax.measure.Quantity<Q>> extends Object implements javax.measure.spi.QuantityFactory<Q>
A factory producing simple quantities instances (tuples Number/ Unit).
For example:
Mass m = DefaultQuantityFactory.getInstance(Mass.class).create(23.0, KILOGRAM); // 23.0 kg
Time m = DefaultQuantityFactory.getInstance(Time.class).create(124, MILLI(SECOND)); // 124 ms
Since:
1.0
Version:
1.1, $Date: 2018-03-04 $
  • Field Details

    • INSTANCES

      static final Map<Class,javax.measure.spi.QuantityFactory> INSTANCES
    • logger

      static final Logger logger
    • LOG_LEVEL

      static final Level LOG_LEVEL
    • type

      private final Class<Q extends javax.measure.Quantity<Q>> type
      The type of the quantities created by this factory.
    • metricUnit

      private final javax.measure.Unit<Q extends javax.measure.Quantity<Q>> metricUnit
      The metric unit for quantities created by this factory.
    • CLASS_TO_METRIC_UNIT

      static final Map<Class,javax.measure.Unit> CLASS_TO_METRIC_UNIT
  • Constructor Details

    • DefaultQuantityFactory

      DefaultQuantityFactory(Class<Q> quantity)
  • Method Details

    • getInstance

      public static <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getInstance(Class<Q> type)
      Returns the default instance for the specified quantity type.
      Type Parameters:
      Q - The type of the quantity
      Parameters:
      type - the quantity type
      Returns:
      the quantity factory for the specified type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • create

      public javax.measure.Quantity<Q> create(Number value, javax.measure.Unit<Q> unit)
      Specified by:
      create in interface javax.measure.spi.QuantityFactory<Q extends javax.measure.Quantity<Q>>
    • getSystemUnit

      public javax.measure.Unit<Q> getSystemUnit()
      Specified by:
      getSystemUnit in interface javax.measure.spi.QuantityFactory<Q extends javax.measure.Quantity<Q>>