Package tech.units.indriya.quantity
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 java.lang.Object implements javax.measure.spi.QuantityFactory<Q>
A factory producing simple quantities instances (tuplesNumber
/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 Summary
Fields Modifier and Type Field Description (package private) static java.util.Map<java.lang.Class,javax.measure.Unit>
CLASS_TO_METRIC_UNIT
(package private) static java.util.Map<java.lang.Class,javax.measure.spi.QuantityFactory>
INSTANCES
(package private) static java.util.logging.Level
LOG_LEVEL
(package private) static java.util.logging.Logger
logger
private javax.measure.Unit<Q>
metricUnit
The metric unit for quantities created by this factory.private java.lang.Class<Q>
type
The type of the quantities created by this factory.
-
Constructor Summary
Constructors Constructor Description DefaultQuantityFactory(java.lang.Class<Q> quantity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.measure.Quantity<Q>
create(java.lang.Number value, javax.measure.Unit<Q> unit)
boolean
equals(java.lang.Object obj)
static <Q extends javax.measure.Quantity<Q>>
javax.measure.spi.QuantityFactory<Q>getInstance(java.lang.Class<Q> type)
Returns the default instance for the specified quantity type.javax.measure.Unit<Q>
getSystemUnit()
int
hashCode()
java.lang.String
toString()
-
-
-
Field Detail
-
INSTANCES
static final java.util.Map<java.lang.Class,javax.measure.spi.QuantityFactory> INSTANCES
-
logger
static final java.util.logging.Logger logger
-
LOG_LEVEL
static final java.util.logging.Level LOG_LEVEL
-
type
private final java.lang.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 java.util.Map<java.lang.Class,javax.measure.Unit> CLASS_TO_METRIC_UNIT
-
-
Constructor Detail
-
DefaultQuantityFactory
DefaultQuantityFactory(java.lang.Class<Q> quantity)
-
-
Method Detail
-
getInstance
public static <Q extends javax.measure.Quantity<Q>> javax.measure.spi.QuantityFactory<Q> getInstance(java.lang.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 java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-