src/share/classes/java/util/function/DoubleConsumer.java

Print this page
rev 7675 : 8019840: Spec updates for java.util.function
Reviewed-by: mduigou
Contributed-by: brian.goetz@oracle.com

@@ -25,44 +25,43 @@
 package java.util.function;
 
 import java.util.Objects;
 
 /**
- * An operation which accepts a single double argument and returns no result.
- * This is the primitive type specialization of {@link Consumer} for
- * {@code double}. Unlike most other functional interfaces,
+ * Represents an operation that accepts a single {@code double}-valued argument and
+ * returns no result.  This is the primitive type specialization of
+ * {@link Consumer} for {@code double}.  Unlike most other functional interfaces,
  * {@code DoubleConsumer} is expected to operate via side-effects.
  *
+ * <p>This is a <a href="package-summary.html">functional interface</a>
+ * whose functional method is {@link #accept(double)}.
+ *
  * @see Consumer
  * @since 1.8
  */
 @FunctionalInterface
 public interface DoubleConsumer {
 
     /**
-     * Accept an input value.
+     * Performs this operation on the given argument.
      *
-     * @param value the input value
+     * @param value the input argument
      */
     void accept(double value);
 
     /**
-     * Returns a {@code DoubleConsumer} which performs, in sequence, the operation
-     * represented by this object followed by the operation represented by
-     * another {@code DoubleConsumer}.
-     *
-     * <p>Any exceptions thrown by either {@code accept} method are relayed
-     * to the caller; if performing this operation throws an exception, the
-     * other operation will not be performed.
+     * Returns a composed {@code DoubleConsumer} that performs, in sequence, this
+     * operation followed by the {@code after} operation. If performing either
+     * operation throws an exception, it is relayed to the caller of the
+     * composed operation.  If performing this operation throws an exception,
+     * the {@code after} operation will not be performed.
      *
-     * @param other a DoubleConsumer which will be chained after this
-     * DoubleConsumer
-     * @return an DoubleConsumer which performs in sequence the {@code accept} method
-     * of this DoubleConsumer and the {@code accept} method of the specified IntConsumer
-     * operation
-     * @throws NullPointerException if other is null
+     * @param after the operation to perform after this operation
+     * @return a composed {@code DoubleConsumer} that performs in sequence this
+     * operation followed by the {@code after} operation
+     * @throws NullPointerException if {@code after} is null
      */
-    default DoubleConsumer chain(DoubleConsumer other) {
-        Objects.requireNonNull(other);
-        return (double t) -> { accept(t); other.accept(t); };
+    default DoubleConsumer andThen(DoubleConsumer after) {
+        Objects.requireNonNull(after);
+        return (double t) -> { accept(t); after.accept(t); };
     }
 }