Class StringInvoker

java.lang.Object
microsim.statistics.reflectors.StringInvoker
All Implemented Interfaces:
StringSource

public class StringInvoker extends Object implements StringSource
Employs Java reflection to call objects' methods which return string values.
  • Field Details

    • method

      protected Method method
    • field

      protected Field field
    • target

      protected Object target
  • Constructor Details

    • StringInvoker

      public StringInvoker(@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.
    • StringInvoker

      public StringInvoker(@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

    • getString

      public String getString(@NonNull @NonNull Object target)
      Invokes the method of the target object and returns its string result.
      Parameters:
      target - Object to be invoked.
      Returns:
      The requested string value.
      Throws:
      NullPointerException - when target is null.
    • getString

      public String getString()
      Invokes the method of the object passed to constructor and returns its double result.
      Returns:
      The requested double value.
    • getStringValue

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

      @NonNull public @NonNull String[] getCollectionValue(@NonNull @NonNull Collection<?> c)
      Converts a collection of strings to an array.
      Parameters:
      c - A Collection object.
      Returns:
      an array.