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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDoubleInvoker(@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.doubleInvokes the method of the object passed to constructor and return its double result.doubleInvokes the method of the target object and return its double result.doublegetDoubleValue(@Nullable Enum<?> valueID) This is an implementation of theDoubleSourceinterface.
-
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- whentargetisnull.
-
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 theDoubleSourceinterface. It calls thegetDouble()method.- Specified by:
getDoubleValuein interfaceDoubleSource- Parameters:
valueID- This parameter is ignored. It is put for compatibility with theDoubleSourceinterface.- Returns:
- The requested double value.
-
getCollectionValue
Converts a collection to an array of doubles.- Parameters:
c- ACollectionobject.- Returns:
- an array.
- Throws:
NullPointerException- whencisnull.
-