Package microsim.statistics.reflectors
Class DoubleInvoker
java.lang.Object
microsim.statistics.reflectors.DoubleInvoker
- All Implemented Interfaces:
DoubleSource
Employs Java reflection to call objects' methods which return double values.
-
Nested Class Summary
Nested classes/interfaces inherited from interface microsim.statistics.DoubleSource
DoubleSource.Variables
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDoubleInvoker
(@NonNull Class<?> target, @NonNull String fieldName, boolean isMethod) Constructor.DoubleInvoker
(@NonNull Object target, @NonNull String fieldName, boolean isMethod) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondouble @NonNull []
getCollectionValue
(@NonNull Collection<?> c) Converts a collection to an array of doubles.double
Invokes the method of the object passed to constructor and return its double result.double
Invokes the method of the target object and return its double result.double
getDoubleValue
(@Nullable Enum<?> valueID) This is an implementation of theDoubleSource
interface.
-
Field Details
-
method
-
field
-
target
-
-
Constructor Details
-
DoubleInvoker
public DoubleInvoker(@NonNull @NonNull Object target, @NonNull @NonNull String fieldName, boolean isMethod) Constructor.- Parameters:
target
- It is the target object.fieldName
- A string representing the name of the method to invoke.isMethod
- If true the fieldName is a method, otherwise it is a property of the object.- Throws:
NullPointerException
- when any of the input parameters isnull
.
-
DoubleInvoker
public DoubleInvoker(@NonNull @NonNull Class<?> target, @NonNull @NonNull String fieldName, boolean isMethod) Constructor.- Parameters:
target
- It is the class of the target object.fieldName
- A string representing the name of the method to invoke.isMethod
- If true the fieldName is a method, otherwise it is a property of the object.- Throws:
NullPointerException
- when any of the input parameters isnull
.
-
-
Method Details
-
getDouble
Invokes the method of the target object and return its double result.- Parameters:
target
- Object to be invoked.- Returns:
- The requested double value.
- Throws:
NullPointerException
- whentarget
isnull
.
-
getDouble
public double getDouble()Invokes the method of the object passed to constructor and return its double result.- Returns:
- The requested double value.
-
getDoubleValue
This is an implementation of theDoubleSource
interface. It calls thegetDouble()
method.- Specified by:
getDoubleValue
in interfaceDoubleSource
- Parameters:
valueID
- This parameter is ignored. It is put for compatibility with theDoubleSource
interface.- Returns:
- The requested double value.
-
getCollectionValue
Converts a collection to an array of doubles.- Parameters:
c
- ACollection
object.- Returns:
- an array.
- Throws:
NullPointerException
- whenc
isnull
.
-