Interface Consumer<D,S>

Type Parameters:
D - the parameter type
S - the acted-upon type
All Known Subinterfaces:
InitConsumer<D,S>

public interface Consumer<D,S>
A parametrized action on a stateful class. Action may be by side-effect modification, cloning derivation or any other polymorphic technique. The static type of the state object must not change.

Prototypic instances of consumers are setter methods, I/O write operations and collection updates such as .

  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends S>
    T
    consume(D argument, T state)
    Act on something.
    default S
    fold(S initialState, Iterable<? extends D> things)
     
  • Method Details

    • consume

      <T extends S> T consume(D argument, T state)
      Act on something.
      Type Parameters:
      T - the static type of the state that is invariant under the action
      Parameters:
      argument - the parameter value
      state - the pre-state. This object may be modified if and only if it is also returned.
      Returns:
      the post-state, either the same object as state or type-equivalent.
    • fold

      default S fold(S initialState, Iterable<? extends D> things)