Interface OutputConverter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface OutputConverter
Converts a value an action returned with ActionResult.set(java.util.Map) to the type of a setter, as the rule's expression language understands its own values. The engine builds one for each rule from its language's convertOutput, and gives it to the engine's OutputWriter with OutputWriter.set(Object, String, Object, OutputConverter), which calls it with the type of a setter when the value as it is fits none.

Implemented by the engine. A writer of an application's own calls it, and a test may implement it to give such a writer a conversion of its own.

  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Object
    convert(@Nullable Object value, Class<?> target)
    Converts a value to one the target type accepts, as the language understands the value, or returns it unchanged where the language has no opinion.
  • Method Details

    • convert

      @Nullable Object convert(@Nullable Object value, Class<?> target)
      Converts a value to one the target type accepts, as the language understands the value, or returns it unchanged where the language has no opinion. The engine's converter returns null unchanged, without asking the language.
      Parameters:
      value - The value an action returned, or null
      target - The type to convert it to: a setter's parameter type, which can be primitive, such as int.class
      Returns:
      The converted value, or value where the language has no conversion for the target; null is a value too
      Throws:
      IllegalArgumentException - if the language refuses the conversion, as it does a value that would lose precision or overflow the target; a language's message is expected to name the value and the target (see convertOutput)