Interface LazyValue<S,T>

Type Parameters:
S - type of the input object used to determine the value
T - type of the output value
All Known Subinterfaces:
LazyBooleanValue<S>, LazyNumericValue<S>, LazyStringValue<S>
All Known Implementing Classes:
MeasurementListValue

public interface LazyValue<S,T>
Interface that can generate a 'lazy' value from an object.

Values can have any type, but are generally expected to be Boolean, Number or String.

  • Field Details

    • DEFAULT_DECIMAL_PLACES

      static final int DEFAULT_DECIMAL_PLACES
      Constant representing that the default number of decimal places should be used to convert floating point numbers to strings.
      See Also:
  • Method Details

    • create

      static <S, T> LazyValue<S,T> create(String name, String helpText, Function<S,T> fun, Class<T> valueType)
      Create a LazyValue with specified name and help text.
      Type Parameters:
      S - input type
      T - value type
      Parameters:
      name - name
      helpText - help text or description
      fun - function to calculate the value
      valueType - return type of the function
      Returns:
      a new lazy value
    • createNumeric

      static <S> LazyNumericValue<S> createNumeric(String name, String helpText, Function<S,Number> fun)
      Create a LazyNumericValue with specified name and help text.
      Type Parameters:
      S - input type
      Parameters:
      name - name
      helpText - help text or description
      fun - function to calculate the value
      Returns:
      a new lazy value
    • createString

      static <S> LazyStringValue<S> createString(String name, String helpText, Function<S,String> fun)
      Create a LazyStringValue with specified name and help text.
      Type Parameters:
      S - input type
      Parameters:
      name - name
      helpText - help text or description
      fun - function to calculate the value
      Returns:
      a new lazy value
    • createBoolean

      static <S> LazyBooleanValue<S> createBoolean(String name, String helpText, Function<S,Boolean> fun)
      Create a LazyBooleanValue with specified name and help text.
      Type Parameters:
      S - input type
      Parameters:
      name - name
      helpText - help text or description
      fun - function to calculate the value
      Returns:
      a new lazy value
    • getName

      String getName()
      The name of the value. When showing a measurement table, this would be the column header.
      Returns:
      the name of the value
    • getMeasurementType

      Class<T> getMeasurementType()
      Get the generic type of the measurement.
      Returns:
    • isNumeric

      default boolean isNumeric()
      Check whether the value returned by this measurement is an instance of Number.
      Returns:
    • isString

      default boolean isString()
      Check whether the value returned by this measurement is an instance of String.
      Returns:
    • isBoolean

      default boolean isBoolean()
      Check whether the value returned by this measurement is an instance of Boolean.
      Returns:
    • getValue

      T getValue(S input)
      Calculate a value from the input.
      Parameters:
      input - the input that should be measured
      Returns:
      the output value
    • getStringValue

      default String getStringValue(S input, int decimalPlaces)
      Get a default string representation of an object measurement.
      Parameters:
      input - the object to measure
      decimalPlaces - number of decimal places; if < 0 then this will be calculated automatically
      Returns:
    • getStringValue

      default String getStringValue(S input)
      Get a default string representation of an object measurement. If the value is numeric, it is converted to a string using the default number of decimal places.
      Parameters:
      input - the object to measure
      Returns:
      See Also:
    • getHelpText

      String getHelpText()
      Optional help text that explained the value. This may be displayed in a tooltip.
      Returns:
      the help text, or null if no help text is available