jdk/src/share/classes/java/util/function/LongConsumer.java
changeset 17695 032254f2467b
parent 16011 890a7ed97f6c
child 19040 7b25fde2a4ed
equal deleted inserted replaced
17694:31d23e077ab3 17695:032254f2467b
    22  * or visit www.oracle.com if you need additional information or have any
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 package java.util.function;
    25 package java.util.function;
    26 
    26 
       
    27 import java.util.Objects;
       
    28 
    27 /**
    29 /**
    28  * An operation which accepts a single long argument and returns no result.
    30  * An operation which accepts a single long argument and returns no result.
    29  * This is the {@code long}-consuming primitive type specialization of
    31  * This is the {@code long}-consuming primitive type specialization of
    30  * {@link Consumer}. Unlike most other functional interfaces, {@code LongConsumer}
    32  * {@link Consumer}. Unlike most other functional interfaces, {@code LongConsumer}
    31  * is expected to operate via side-effects.
    33  * is expected to operate via side-effects.
    39     /**
    41     /**
    40      * Accept an input value.
    42      * Accept an input value.
    41      *
    43      *
    42      * @param value the input value
    44      * @param value the input value
    43      */
    45      */
    44     public void accept(long value);
    46     void accept(long value);
       
    47 
       
    48     /**
       
    49      * Returns a {@code LongConsumer} which performs, in sequence, the operation
       
    50      * represented by this object followed by the operation represented by
       
    51      * another {@code LongConsumer}.
       
    52      *
       
    53      * <p>Any exceptions thrown by either {@code accept} method are relayed
       
    54      * to the caller; if performing this operation throws an exception, the
       
    55      * other operation will not be performed.
       
    56      *
       
    57      * @param other a LongConsumer which will be chained after this
       
    58      * LongConsumer
       
    59      * @return a LongConsumer which performs in sequence the {@code accept} method
       
    60      * of this LongConsumer and the {@code accept} method of the specified LongConsumer
       
    61      * operation
       
    62      * @throws NullPointerException if other is null
       
    63      */
       
    64     default LongConsumer chain(LongConsumer other) {
       
    65         Objects.requireNonNull(other);
       
    66         return (long t) -> { accept(t); other.accept(t); };
       
    67     }
    45 }
    68 }