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