Interface Task

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 Task
  • Method Summary

    Modifier and Type
    Method
    Description
    run(Example example)
    Run the task on the given Example and produce outputs.
    static <T> Task
    Creates a Task that produces a single typed value and stores it under the conventional "output" key, so callers can return a record, list, or other POJO from their task body instead of hand-building the output map.
  • Method Details

    • run

      Map<String,Object> run(Example example)
      Run the task on the given Example and produce outputs.
      Parameters:
      example - the example containing inputs and expected outputs
      Returns:
      the actual outputs produced by the task
    • typed

      static <T> Task typed(Function<Example,T> fn)
      Creates a Task that produces a single typed value and stores it under the conventional "output" key, so callers can return a record, list, or other POJO from their task body instead of hand-building the output map.

      The produced value is read back type-safely via actualOutputAs(...) on the resulting EvalTestCase and is matched structurally by StructuralMatchEvaluator.

      Map guard: if fn itself returns a Map, that map is used directly as the output map rather than being nested under "output". The map is assumed to use String keys.

      Type Parameters:
      T - the produced value type
      Parameters:
      fn - the function producing the output value for an Example (may return a Map, which is used as the output map directly)
      Returns:
      a Task that wraps the produced value under "output" (or uses a returned map directly)
      Throws:
      NullPointerException - if fn returns null (the output map cannot hold a null value; use a raw Task if an absent output is intended)