aoqi@0: /**
aoqi@0: * Performs operations upon an input object which may modify that object and/or
aoqi@0: * external state (other objects).
aoqi@0: *
aoqi@0: *
All block implementations are expected to:
aoqi@0: *
aoqi@0: * - When used for aggregate operations upon many elements blocks
aoqi@0: * should not assume that the {@code apply} operation will be called upon
aoqi@0: * elements in any specific order.
aoqi@0: *
aoqi@0: *
aoqi@0: * @param The type of input objects to {@code apply}.
aoqi@0: */
aoqi@0: public interface TBlock {
aoqi@0:
aoqi@0: /**
aoqi@0: * Performs operations upon the provided object which may modify that object
aoqi@0: * and/or external state.
aoqi@0: *
aoqi@0: * @param t an input object
aoqi@0: */
aoqi@0: void apply(T t);
aoqi@0:
aoqi@0: /**
aoqi@0: * Returns a Block which performs in sequence the {@code apply} methods of
aoqi@0: * multiple Blocks. This Block's {@code apply} method is performed followed
aoqi@0: * by the {@code apply} method of the specified Block operation.
aoqi@0: *
aoqi@0: * @param other an additional Block which will be chained after this Block
aoqi@0: * @return a Block which performs in sequence the {@code apply} method of
aoqi@0: * this Block and the {@code apply} method of the specified Block operation
aoqi@0: */
aoqi@0: public default TBlock chain(TBlock super T> other) {
aoqi@0: return (T t) -> { apply(t); other.apply(t); };
aoqi@0: }
aoqi@0: }