Package io.github.brantunger.unruly.api
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.
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
-
Method Details
-
convert
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 returnsnullunchanged, without asking the language.- Parameters:
value- The value an action returned, ornulltarget- The type to convert it to: a setter's parameter type, which can be primitive, such asint.class- Returns:
- The converted value, or
valuewhere the language has no conversion for the target;nullis 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 (seeconvertOutput)
-