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

Print this page
rev 6189 : 8004015: Add Extends and deaults for basic functional interface types
Summary: Adds the appropriate extends and default methods for  core functional interfaces used by the JSR335 libraries.
Reviewed-by: duke

@@ -26,13 +26,30 @@
 
 /**
  * An operation on a single {@code double} operand yielding a {@code double}
  * result.
  *
+ * <p>This is the primitive type specialization of {@link UnaryOperator} for
+ * {@code double} and also may be used as a {@code UnaryOperator<Double>}. When
+ * used as a {@code UnaryOperator} the default {@code operate} implementation
+ * provided by this interface neither accepts null parameters nor does it return
+ * null results.
+ *
  * @since 1.8
  */
-public interface DoubleUnaryOperator {
+public interface DoubleUnaryOperator extends UnaryOperator<Double> {
+
+    /**
+     * {@inheritDoc}
+     *
+     * @param operand {@inheritDoc}, must be non-null
+     * @return {@inheritDoc}, always non-null
+     */
+    @Override
+    public default Double operate(Double operand) {
+        return operateAsDouble((double)operand);
+    }
 
     /**
      * Returns the {@code double} result of the operation upon the
      * {@code double} operand.
      *