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 Object
implements javax.measure.spi.QuantityFactory<Q>
A factory producing simple quantities instances (tuples
For example:
Number
/Unit
). This implementation of QuantityFactory
uses the
DynamicProxy features of Java reflection API.For example:
Quantity m = 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 ClassesModifier and TypeClassDescriptionprivate static final class
ProxyQuantityFactory.Default<Q extends javax.measure.Quantity<Q>>
The default factory implementation.private static final class
ProxyQuantityFactory.GenericHandler<Q extends javax.measure.Quantity<Q>>
The method invocation handler for implementation backed by any kind ofNumber
. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <Q extends javax.measure.Quantity<Q>>
ProxyQuantityFactory<Q> getInstance
(Class<Q> type) Returns the default instance for the specified quantity type.abstract javax.measure.Unit
<Q> Returns the metric unit for quantities produced by this factory ornull
if unknown.protected static <Q extends javax.measure.Quantity<Q>>
voidsetInstance
(Class<Q> type, ProxyQuantityFactory<Q> factory) Overrides the default implementation of the factory for the specified quantity type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.measure.spi.QuantityFactory
create
-
Field Details
-
INSTANCES
Holds the current instances. -
logger
-
LOG_LEVEL
-
-
Constructor Details
-
ProxyQuantityFactory
public ProxyQuantityFactory()
-
-
Method Details
-
getInstance
public static <Q extends javax.measure.Quantity<Q>> ProxyQuantityFactory<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
-
setInstance
protected static <Q extends javax.measure.Quantity<Q>> void setInstance(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
Returns the metric unit for quantities produced by this factory ornull
if unknown.
-