src/share/classes/java/util/OptionalDouble.java

Print this page
rev 8872 : 8028816: Add value-type notice to Optional* classes
Reviewed-by: mduigou
Contributed-by: brian.goetz@oracle.com, bitterfoxc@gmail.com

*** 29,46 **** import java.util.function.Supplier; /** * A container object which may or may not contain a {@code double} value. * If a value is present, {@code isPresent()} will return {@code true} and ! * {@code get()} will return the value. * * <p>Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(double) orElse()} * (return a default value if value not present) and * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block * of code if the value is present). * * @since 1.8 */ public final class OptionalDouble { /** * Common instance for {@code empty()}. --- 29,51 ---- import java.util.function.Supplier; /** * A container object which may or may not contain a {@code double} value. * If a value is present, {@code isPresent()} will return {@code true} and ! * {@code getAsDouble()} will return the value. * * <p>Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(double) orElse()} * (return a default value if value not present) and * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block * of code if the value is present). * + * <p>This is a <a href="../lang/doc-files/ValueBased.html">value-based</a> + * class; use of identity-sensitive operations (including reference equality + * ({@code ==}), identity hash code, or synchronization) on instances of + * {@code OptionalDouble} may have unpredictable effects and should be avoided. + * * @since 1.8 */ public final class OptionalDouble { /** * Common instance for {@code empty()}.