langtools/test/tools/javac/lambda/lambdaExecution/TBlock.java
changeset 14554 4e29b285c723
child 37633 d16d6d59446d
equal deleted inserted replaced
14553:b2fd2388dd46 14554:4e29b285c723
       
     1 /**
       
     2  * Performs operations upon an input object which may modify that object and/or
       
     3  * external state (other objects).
       
     4  *
       
     5  * <p>All block implementations are expected to:
       
     6  * <ul>
       
     7  * <li>When used for aggregate operations upon many elements blocks
       
     8  * should not assume that the {@code apply} operation will be called upon
       
     9  * elements in any specific order.</li>
       
    10  * </ul>
       
    11  *
       
    12  * @param <T> The type of input objects to {@code apply}.
       
    13  */
       
    14 public interface TBlock<T> {
       
    15 
       
    16     /**
       
    17      * Performs operations upon the provided object which may modify that object
       
    18      * and/or external state.
       
    19      *
       
    20      * @param t an input object
       
    21      */
       
    22     void apply(T t);
       
    23 
       
    24     /**
       
    25      * Returns a Block which performs in sequence the {@code apply} methods of
       
    26      * multiple Blocks. This Block's {@code apply} method is performed followed
       
    27      * by the {@code apply} method of the specified Block operation.
       
    28      *
       
    29      * @param other an additional Block which will be chained after this Block
       
    30      * @return a Block which performs in sequence the {@code apply} method of
       
    31      * this Block and the {@code apply} method of the specified Block operation
       
    32      */
       
    33     public default TBlock<T> chain(TBlock<? super T> other) {
       
    34         return (T t) -> { apply(t); other.apply(t); };
       
    35     }
       
    36 }