Package org.apache.sis.measure
Class ScalarFallback<Q extends javax.measure.Quantity<Q>>
java.lang.Object
java.lang.Number
org.apache.sis.measure.Scalar<Q>
org.apache.sis.measure.ScalarFallback<Q>
- Type Parameters:
Q
- the type of quantity implemented by this scalar.
- All Implemented Interfaces:
Serializable
,Comparable<Q>
,InvocationHandler
,javax.measure.Quantity<Q>
final class ScalarFallback<Q extends javax.measure.Quantity<Q>>
extends Scalar<Q>
implements InvocationHandler
Fallback used when no
Scalar
implementation is available for a given quantity type.- Since:
- 0.8
- Version:
- 0.8
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.measure.Scalar
Scalar.Acceleration, Scalar.Angle, Scalar.Area, Scalar.Dimensionless, Scalar.Energy, Scalar.Force, Scalar.Frequency, Scalar.Length, Scalar.Mass, Scalar.Power, Scalar.Pressure, Scalar.Speed, Scalar.Temperature, Scalar.Time, Scalar.Volume
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ScalarFallback
(double value, javax.measure.Unit<Q> unit, Class<Q> type) Creates a new scalar for the given value and unit of measurement. -
Method Summary
Modifier and TypeMethodDescription(package private) javax.measure.Quantity
<Q> Creates a new quantity of the same type than this quantity but a different value and/or unit.(package private) static <Q extends javax.measure.Quantity<Q>>
QCreates a newScalarFallback
instance implementing the given quantity type.Invoked when a method of theQuantity
interface is invoked.
-
Field Details
-
type
The type implemented by proxy instances.
-
-
Constructor Details
-
ScalarFallback
Creates a new scalar for the given value and unit of measurement. Callers should ensure that all the arguments are non-null.
-
-
Method Details
-
create
Creates a new quantity of the same type than this quantity but a different value and/or unit. -
factory
static <Q extends javax.measure.Quantity<Q>> Q factory(double value, javax.measure.Unit<Q> unit, Class<Q> type) Creates a newScalarFallback
instance implementing the given quantity type. Callers should ensure that all the arguments are non-null.- Parameters:
value
- the numerical value.unit
- unit of measurement.type
- interface implemented by proxy instances.
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws ReflectiveOperationException Invoked when a method of theQuantity
interface is invoked. Delegates to the same method of the parentScalar
class. This works not only for the quantity methods, but also forScalar.toString()
,Scalar.hashCode()
andScalar.equals(Object)
.- Specified by:
invoke
in interfaceInvocationHandler
- Throws:
ReflectiveOperationException
-