Package tech.units.indriya.quantity
Class ProxyQuantityFactory<Q extends javax.measure.Quantity<Q>>
- java.lang.Object
-
- tech.units.indriya.quantity.ProxyQuantityFactory<Q>
-
- Type Parameters:
Q- The type of the quantity.
- All Implemented Interfaces:
javax.measure.spi.QuantityFactory<Q>
- Direct Known Subclasses:
ProxyQuantityFactory.Default
public abstract class ProxyQuantityFactory<Q extends javax.measure.Quantity<Q>> extends java.lang.Object implements javax.measure.spi.QuantityFactory<Q>A factory producing simple quantities instances (tuplesNumber/Unit). This implementation ofQuantityFactoryuses the DynamicProxy features of Java reflection API.
For example:
Quantitym = ProxyQuantityFactory.getInstance(Mass.class).create(23.0, KILOGRAM); // 23.0 kg
Quantity- Since:
- 1.0
- Version:
- 1.1, $Date: 2018-03-04 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classProxyQuantityFactory.Default<Q extends javax.measure.Quantity<Q>>The default factory implementation.private static classProxyQuantityFactory.GenericHandler<Q extends javax.measure.Quantity<Q>>The method invocation handler for implementation backed by any kind ofNumber.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Class,ProxyQuantityFactory>INSTANCESHolds the current instances.private static java.util.logging.LevelLOG_LEVELprivate static java.util.logging.Loggerlogger
-
Constructor Summary
Constructors Constructor Description ProxyQuantityFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <Q extends javax.measure.Quantity<Q>>
ProxyQuantityFactory<Q>getInstance(java.lang.Class<Q> type)Returns the default instance for the specified quantity type.abstract javax.measure.Unit<Q>getSystemUnit()Returns the metric unit for quantities produced by this factory ornullif unknown.protected static <Q extends javax.measure.Quantity<Q>>
voidsetInstance(java.lang.Class<Q> type, ProxyQuantityFactory<Q> factory)Overrides the default implementation of the factory for the specified quantity type.
-
-
-
Field Detail
-
INSTANCES
private static final java.util.Map<java.lang.Class,ProxyQuantityFactory> INSTANCES
Holds the current instances.
-
logger
private static final java.util.logging.Logger logger
-
LOG_LEVEL
private static final java.util.logging.Level LOG_LEVEL
-
-
Method Detail
-
getInstance
public static <Q extends javax.measure.Quantity<Q>> ProxyQuantityFactory<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
-
setInstance
protected static <Q extends javax.measure.Quantity<Q>> void setInstance(java.lang.Class<Q> type, ProxyQuantityFactory<Q> factory)Overrides the default implementation of the factory for the specified quantity type.- Type Parameters:
Q- The type of the quantity- Parameters:
type- the quantity typefactory- the quantity factory
-
getSystemUnit
public abstract javax.measure.Unit<Q> getSystemUnit()
Returns the metric unit for quantities produced by this factory ornullif unknown.
-
-