Package microsim.statistics.reflectors
Class IntegerInvoker
java.lang.Object
microsim.statistics.reflectors.IntegerInvoker
- All Implemented Interfaces:
IntSource
Employs Java reflection to call objects' methods which return integer values.
-
Nested Class Summary
Nested classes/interfaces inherited from interface microsim.statistics.IntSource
IntSource.Variables
-
Field Summary
-
Constructor Summary
ConstructorDescriptionIntegerInvoker
(@NonNull Class<?> target, @NonNull String fieldName, boolean isMethod) Constructor.IntegerInvoker
(@NonNull Object target, @NonNull String fieldName, boolean isMethod) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
getInt()
Invokes the method of the object passed to constructor and return its double result.int
Invokes the method of the target object and return its double result.int
getIntValue
(@Nullable Enum<?> valueID) This is an implementation of theIntSource
interface.
-
Field Details
-
method
-
field
-
target
-
-
Constructor Details
-
IntegerInvoker
public IntegerInvoker(@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
.
-
IntegerInvoker
public IntegerInvoker(@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
-
getInt
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
.
-
getInt
public int getInt()Invokes the method of the object passed to constructor and return its double result.- Returns:
- The requested double value.
-
getIntValue
This is an implementation of theIntSource
interface. It calls thegetInt(Object)
method.- Specified by:
getIntValue
in interfaceIntSource
- Parameters:
valueID
- This parameter is ignored. It is put for compatibility with theIntSource
interface.- Returns:
- The requested double value.
-