29 import java.util.function.Supplier; |
29 import java.util.function.Supplier; |
30 |
30 |
31 /** |
31 /** |
32 * A container object which may or may not contain a {@code double} value. |
32 * A container object which may or may not contain a {@code double} value. |
33 * If a value is present, {@code isPresent()} will return {@code true} and |
33 * If a value is present, {@code isPresent()} will return {@code true} and |
34 * {@code get()} will return the value. |
34 * {@code getAsDouble()} will return the value. |
35 * |
35 * |
36 * <p>Additional methods that depend on the presence or absence of a contained |
36 * <p>Additional methods that depend on the presence or absence of a contained |
37 * value are provided, such as {@link #orElse(double) orElse()} |
37 * value are provided, such as {@link #orElse(double) orElse()} |
38 * (return a default value if value not present) and |
38 * (return a default value if value not present) and |
39 * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block |
39 * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block |
40 * of code if the value is present). |
40 * of code if the value is present). |
|
41 * |
|
42 * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a> |
|
43 * class; use of identity-sensitive operations (including reference equality |
|
44 * ({@code ==}), identity hash code, or synchronization) on instances of |
|
45 * {@code OptionalDouble} may have unpredictable results and should be avoided. |
41 * |
46 * |
42 * @since 1.8 |
47 * @since 1.8 |
43 */ |
48 */ |
44 public final class OptionalDouble { |
49 public final class OptionalDouble { |
45 /** |
50 /** |