test/tools/javac/lambda/lambdaExecution/TBlock.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/lambdaExecution/TBlock.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,36 @@
     1.4 +/**
     1.5 + * Performs operations upon an input object which may modify that object and/or
     1.6 + * external state (other objects).
     1.7 + *
     1.8 + * <p>All block implementations are expected to:
     1.9 + * <ul>
    1.10 + * <li>When used for aggregate operations upon many elements blocks
    1.11 + * should not assume that the {@code apply} operation will be called upon
    1.12 + * elements in any specific order.</li>
    1.13 + * </ul>
    1.14 + *
    1.15 + * @param <T> The type of input objects to {@code apply}.
    1.16 + */
    1.17 +public interface TBlock<T> {
    1.18 +
    1.19 +    /**
    1.20 +     * Performs operations upon the provided object which may modify that object
    1.21 +     * and/or external state.
    1.22 +     *
    1.23 +     * @param t an input object
    1.24 +     */
    1.25 +    void apply(T t);
    1.26 +
    1.27 +    /**
    1.28 +     * Returns a Block which performs in sequence the {@code apply} methods of
    1.29 +     * multiple Blocks. This Block's {@code apply} method is performed followed
    1.30 +     * by the {@code apply} method of the specified Block operation.
    1.31 +     *
    1.32 +     * @param other an additional Block which will be chained after this Block
    1.33 +     * @return a Block which performs in sequence the {@code apply} method of
    1.34 +     * this Block and the {@code apply} method of the specified Block operation
    1.35 +     */
    1.36 +    public default TBlock<T> chain(TBlock<? super T> other) {
    1.37 +        return (T t) -> { apply(t); other.apply(t); };
    1.38 +    }
    1.39 +}

mercurial