Class DoubleInvoker

java.lang.Object
microsim.statistics.reflectors.DoubleInvoker
All Implemented Interfaces:
DoubleSource

public class DoubleInvoker extends Object implements DoubleSource
Employs Java reflection to call objects' methods which return double values.
  • Field Details

    • method

      protected Method method
    • field

      protected Field field
    • target

      protected Object 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 is null.
    • 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 is null.
  • Method Details

    • getDouble

      public double getDouble(@NonNull @NonNull Object target)
      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 - when target is null.
    • getDouble

      public double getDouble()
      Invokes the method of the object passed to constructor and return its double result.
      Returns:
      The requested double value.
    • getDoubleValue

      public double getDoubleValue(@Nullable @Nullable Enum<?> valueID)
      This is an implementation of the DoubleSource interface. It calls the getDouble() method.
      Specified by:
      getDoubleValue in interface DoubleSource
      Parameters:
      valueID - This parameter is ignored. It is put for compatibility with the DoubleSource interface.
      Returns:
      The requested double value.
    • getCollectionValue

      public double @NonNull [] getCollectionValue(@NonNull @NonNull Collection<?> c)
      Converts a collection to an array of doubles.
      Parameters:
      c - A Collection object.
      Returns:
      an array.
      Throws:
      NullPointerException - when c is null.