Interface Validated.Accumulator<E>

Enclosing interface:
Validated<E,T>

public static interface Validated.Accumulator<E>
The binding handle passed to Validated.accumulate(Function).

Both on overloads are error-covariant: an Accumulator<BankError> accepts Validated<NoSuchAccount, …> and Result<WrongPin, …> where each subtype implements BankError, unifying per-step error subtypes into the block's E with no per-step mapErr. See ADR-11.

  • Method Details

    • on

      <T> Validated.Bound<T> on(Validated<? extends E, T> validated)
      Bind a Validated: a Valid's value becomes available via Validated.Bound.value(); an Invalid's errors are added to the accumulator. Binding never aborts the block; later validations still run.

      The error is consumed covariantly (? extends E), so steps that return a Validated with an error subtype are accepted without mapErr.

    • on

      default <T> Validated.Bound<T> on(Result<? extends E, T> result)
      Bind a Result: Err accumulates as a single error.

      The error is consumed covariantly (? extends E), so steps that return a Result with an error subtype are accepted without mapErr.

    • on

      default <T> Validated.Bound<T> on(Optional<? extends T> maybe, Supplier<? extends E> ifEmpty)
      Bind an Optional: empty accumulates ifEmpty.get().
    • onEach

      default <T,R> Validated.Bound<List<R>> onEach(List<? extends T> items, Function<? super T, ? extends Validated<E,R>> parse)
      Bind a validation of every element of a list (on of a traverse): every failing element contributes its errors, and the Validated.Bound yields the fully-parsed list.
    • ensure

      default void ensure(boolean condition, Supplier<? extends E> error)
      Check a condition with no value to bind: a guard, a limit, a cross-field rule. false records the error and the block keeps running, like every other binding; true records nothing.