changeset 7580:531e2401ca44

javadoc synchronization
author mduigou
date Fri, 08 Mar 2013 08:26:46 -0800
parents 35b2aa2ab27c
children 7e859eed69bd
files src/share/classes/java/util/Optional.java src/share/classes/java/util/OptionalDouble.java src/share/classes/java/util/OptionalInt.java src/share/classes/java/util/OptionalLong.java
diffstat 4 files changed, 260 insertions(+), 148 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/Optional.java	Fri Mar 08 08:26:36 2013 -0800
+++ b/src/share/classes/java/util/Optional.java	Fri Mar 08 08:26:46 2013 -0800
@@ -54,7 +54,7 @@
     /**
      * Construct an empty instance.
      *
-     * @implNote generally only one empty instance, {@link Optional#EMPTY},
+     * @implNote Generally only one empty instance, {@link Optional#EMPTY},
      * should exist per VM.
      */
     private Optional() {
@@ -80,9 +80,9 @@
     }
 
     /**
-     * Construct an instance with a non-null value.
+     * Construct an instance with the value present.
      *
-     * @param value a non-null value
+     * @param value the non-null value to be present
      */
     private Optional(T value) {
         this.value = Objects.requireNonNull(value);
@@ -151,8 +151,8 @@
      * Return the value if present, otherwise invoke {@code other} and return
      * the result of that invocation.
      *
-     * @param other a {@code Supplier} whose result is returned if there is no
-     * value is present
+     * @param other a {@code Supplier} whose result is returned if no value
+     * is present
      * @return the value if present otherwise the result of {@code other.get()}
      * @throws NullPointerException if value is not present and {@code other} is
      * null
@@ -230,7 +230,7 @@
      *
      * @implSpec If a value is present the result must include its string
      * representation in the result. Empty and present Optionals must be
-     * unambiguously identifiable.
+     * unambiguously differentiable.
      *
      * @return the string representation of this instance
      */
--- a/src/share/classes/java/util/OptionalDouble.java	Fri Mar 08 08:26:36 2013 -0800
+++ b/src/share/classes/java/util/OptionalDouble.java	Fri Mar 08 08:26:46 2013 -0800
@@ -34,10 +34,10 @@
  * {@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(java.lang.Object) orElse()}
+ * value are provided, such as {@link #orElse(double) orElse()}
  * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (execute a block
- * of code if the value is present.)
+ * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (execute a block
+ * of code if the value is present).
  *
  * @since 1.8
  */
@@ -45,7 +45,7 @@
     /**
      * Common instance for {@code empty()}.
      */
-    private final static OptionalDouble EMPTY = new OptionalDouble();
+    private static final OptionalDouble EMPTY = new OptionalDouble();
 
     /**
      * If true then the value is present, otherwise indicates no value is present
@@ -54,16 +54,6 @@
     private final double value;
 
     /**
-     * Construct a non-empty instance
-     *
-     * @param value the double value to be present.
-     */
-    private OptionalDouble(double value) {
-        this.isPresent = true;
-        this.value = value;
-    }
-
-    /**
      * Construct an empty instance.
      *
      * @implNote generally only one empty instance, {@link OptionalDouble#EMPTY},
@@ -75,24 +65,35 @@
     }
 
     /**
-     * Return an empty {@code OptionalDouble}.  No value is present for this Optional.
+     * Returns an empty {@code OptionalDouble} instance.  No value is present for this
+	 * OptionalDouble.
      *
      * @apiNote Though it may be tempting to do so, avoid testing if an object
-     * is empty by comparing with {@code ==} against instances returned
+     * is empty by comparing with {@code ==} against instances returned by
      * {@code Option.empty()}. There is no guarantee that it is a singleton.
-     * Instead, use {@code isPresent()}.
+     * Instead, use {@link #isPresent()}.
      *
      *  @return an empty {@code OptionalDouble}.
      */
-    @SuppressWarnings("unchecked")
     public static OptionalDouble empty() {
         return EMPTY;
     }
 
     /**
-     * Create a new {@code OptionalDouble} with a present value
-     * @param value The double value
-     * @param value new {@code OptionalDouble} with a present value.
+     * Construct an instance with the value present.
+     *
+     * @param value the double value to be present.
+     */
+    private OptionalDouble(double value) {
+        this.isPresent = true;
+        this.value = value;
+    }
+
+    /**
+     * Return an {@code OptionalDouble} with the specified value present.
+     *
+     * @param value the value to be present
+     * @return an {@code OptionalDouble} with the value present
      */
     public static OptionalDouble of(double value) {
         return new OptionalDouble(value);
@@ -102,8 +103,8 @@
      * If a value is present in this {@code OptionalDouble}, returns the value,
      * otherwise throws {@code NoSuchElementException}.
      *
-     * @return the value held by this {@code OptionalDouble}.
-     * @throws NoSuchElementException if there is no value present.
+     * @return the value held by this {@code OptionalDouble}
+     * @throws NoSuchElementException if there is no value present
      *
      * @see OptionalDouble#isPresent()
      */
@@ -117,19 +118,19 @@
     /**
      * Return {@code true} if there is a value present, otherwise {@code false}.
      *
-     * @return {@code true} if there is a value present, otherwise {@code false}.
+     * @return {@code true} if there is a value present, otherwise {@code false}
      */
     public boolean isPresent() {
         return isPresent;
     }
 
     /**
-     * Execute the specified consumer with the value if a value is present,
+     * Have the specified consumer accept the value if a value is present,
      * otherwise do nothing.
      *
-     * @param consumer block to be executed if a value is present.
+     * @param consumer block to be executed if a value is present
      * @throws NullPointerException if value is present and {@code consumer} is
-     * null.
+     * null
      */
     public void ifPresent(DoubleConsumer consumer) {
         if (isPresent)
@@ -139,8 +140,8 @@
     /**
      * Return the value if present, otherwise return {@code other}.
      *
-     * @param other value to be returned if there is no value present.
-     * @return the value, if present, otherwise {@code other}.
+     * @param other the value to be returned if there is no value present
+     * @return the value, if present, otherwise {@code other}
      */
     public double orElse(double other) {
         return isPresent ? value : other;
@@ -150,10 +151,11 @@
      * Return the value if present, otherwise invoke {@code other} and return
      * the result of that invocation.
      *
-     * @param other {@code DoubleSupplier} who's result is returned if there is no
-     * value present.
-     * @return the value if present otherwise return result of {@code other}.
-     * @throws NullPointerException if value is absent and {@code other} is null.
+     * @param other a {@code DoubleSupplier} whose result is returned if no value
+     * is present
+     * @return the value if present otherwise the result of {@code other.getAsDouble()}
+     * @throws NullPointerException if value is not present and {@code other} is
+     * null
      */
     public double orElseGet(DoubleSupplier other) {
         return isPresent ? value : other.getAsDouble();
@@ -163,15 +165,19 @@
      * Return the contained value, if present, otherwise throw an exception
      * to be created by the provided supplier.
      *
-     * @param <V> Type of the exception to be thrown.
+     * @apiNote A method reference to the exception constructor with an empty
+     * argument list can be used as the supplier. For example,
+     * {@code IllegalStateException::new}
+     *
+     * @param <X> Type of the exception to be thrown
      * @param exceptionSupplier The supplier which will return the exception to
-     * be thrown.
-     * @return the value.
-     * @throws V if there is no value present.
-     * @throws NullPointerException if value is absent and
-     * {@code exceptionSupplier} is null.
+     * be thrown
+     * @return the present value
+     * @throws X if there is no value present
+     * @throws NullPointerException if no value is present and
+     * {@code exceptionSupplier} is null
      */
-    public<V extends Throwable> double orElseThrow(Supplier<V> exceptionSupplier) throws V {
+    public<X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X {
         if (isPresent) {
             return value;
         } else {
@@ -179,31 +185,61 @@
         }
     }
 
+    /**
+     * Indicates whether some other object is "equal to" this Optional. The
+     * other object is considered equal if:
+     * <ul>
+     * <li>it is also an {@code OptionalInt} and;
+     * <li>both instances have no value present or;
+     * <li>the present values are "equal to" each other via {@code Double.compare() == 0}.
+     * </ul>
+     *
+     * @param obj an object to be tested for equality
+     * @return {code true} if the other object is "equal to" this object
+     * otherwise {@code false}
+     */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object obj) {
+        if (this == obj) {
             return true;
         }
 
-        if (!(o instanceof OptionalDouble)) {
+        if (!(obj instanceof OptionalDouble)) {
             return false;
         }
 
-        OptionalDouble other = (OptionalDouble) o;
+        OptionalDouble other = (OptionalDouble) obj;
         return (isPresent && other.isPresent)
                ? Double.compare(value, other.value) == 0
                : isPresent == other.isPresent;
     }
 
+    /**
+     * Returns the hash code value of the present value, if any, or 0 (zero) if
+     * no value is present.
+     *
+     * @return hash code value of the present value or 0 if no value is present
+     */
     @Override
     public int hashCode() {
         return Double.hashCode(value);
     }
 
+    /**
+     * Returns a non-empty string representation of this OptionalDouble suitable for
+     * debugging. The exact presentation format is unspecified and may vary
+     * between implementations and versions.
+     *
+     * @implSpec If a value is present the result must include its string
+     * representation in the result. Empty and present OptionalDoubless must be
+     * unambiguously differentiable.
+     *
+     * @return the string representation of this instance
+     */
     @Override
     public String toString() {
         return isPresent
-			? String.format("DoubleOptional[%s]", value)
-			: "DoubleOptional.empty";
+			? String.format("OptionalDouble[%s]", value)
+			: "OptionalDouble.empty";
     }
 }
--- a/src/share/classes/java/util/OptionalInt.java	Fri Mar 08 08:26:36 2013 -0800
+++ b/src/share/classes/java/util/OptionalInt.java	Fri Mar 08 08:26:46 2013 -0800
@@ -34,10 +34,10 @@
  * {@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(java.lang.Object) orElse()}
+ * value are provided, such as {@link #orElse(int) orElse()}
  * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (execute a block
- * of code if the value is present.)
+ * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (execute a block
+ * of code if the value is present).
  *
  * @since 1.8
  */
@@ -45,7 +45,7 @@
     /**
      * Common instance for {@code empty()}.
      */
-    private final static OptionalInt EMPTY = new OptionalInt();
+    private static final OptionalInt EMPTY = new OptionalInt();
 
     /**
      * If true then the value is present, otherwise indicates no value is present
@@ -54,19 +54,9 @@
     private final int value;
 
     /**
-     * Construct a non-empty instance
-     *
-     * @param value the int value to be present.
-     */
-    private OptionalInt(int value) {
-        this.isPresent = true;
-        this.value = value;
-    }
-
-    /**
      * Construct an empty instance.
      *
-     * @implNote generally only one empty instance, {@link OptionalInt#EMPTY},
+     * @implNote Generally only one empty instance, {@link OptionalInt#EMPTY},
      * should exist per VM.
      */
     private OptionalInt() {
@@ -75,24 +65,35 @@
     }
 
     /**
-     * Return an empty {@code OptionalInt}.  No value is present for this Optional.
+     * Returns an empty {@code OptionalInt} instance.  No value is present for this
+	 * OptionalInt.
      *
      * @apiNote Though it may be tempting to do so, avoid testing if an object
-     * is empty by comparing with {@code ==} against instances returned
+     * is empty by comparing with {@code ==} against instances returned by
      * {@code Option.empty()}. There is no guarantee that it is a singleton.
-     * Instead, use {@code isPresent()}.
+     * Instead, use {@link #isPresent()}.
      *
-     *  @return an empty {@code OptionalInt}.
+     *  @return an empty {@code OptionalInt}
      */
-    @SuppressWarnings("unchecked")
     public static OptionalInt empty() {
         return EMPTY;
     }
 
     /**
-     * Create a new {@code OptionalInt} with a present value
-     * @param value The int value
-     * @param value new {@code OptionalInt} with a present value.
+     * Construct an instance with the value present.
+     *
+     * @param value the int value to be present
+     */
+    private OptionalInt(int value) {
+        this.isPresent = true;
+        this.value = value;
+    }
+
+    /**
+     * Return an {@code OptionalInt} with the specified value present.
+     *
+     * @param value the value to be present
+     * @return an {@code OptionalInt} with the value present
      */
     public static OptionalInt of(int value) {
         return new OptionalInt(value);
@@ -102,8 +103,8 @@
      * If a value is present in this {@code OptionalInt}, returns the value,
      * otherwise throws {@code NoSuchElementException}.
      *
-     * @return the value held by this {@code OptionalInt}.
-     * @throws NoSuchElementException if there is no value present.
+     * @return the value held by this {@code OptionalInt}
+     * @throws NoSuchElementException if there is no value present
      *
      * @see OptionalInt#isPresent()
      */
@@ -117,19 +118,19 @@
     /**
      * Return {@code true} if there is a value present, otherwise {@code false}.
      *
-     * @return {@code true} if there is a value present, otherwise {@code false}.
+     * @return {@code true} if there is a value present, otherwise {@code false}
      */
     public boolean isPresent() {
         return isPresent;
     }
 
     /**
-     * Execute the specified consumer with the value if a value is present,
+     * Have the specified consumer accept the value if a value is present,
      * otherwise do nothing.
      *
-     * @param consumer block to be executed if a value is present.
+     * @param consumer block to be executed if a value is present
      * @throws NullPointerException if value is present and {@code consumer} is
-     * null.
+     * null
      */
     public void ifPresent(IntConsumer consumer) {
         if (isPresent)
@@ -139,8 +140,8 @@
     /**
      * Return the value if present, otherwise return {@code other}.
      *
-     * @param other value to be returned if there is no value present.
-     * @return the value, if present, otherwise {@code other}.
+     * @param other the value to be returned if there is no value present
+     * @return the value, if present, otherwise {@code other}
      */
     public int orElse(int other) {
         return isPresent ? value : other;
@@ -150,10 +151,11 @@
      * Return the value if present, otherwise invoke {@code other} and return
      * the result of that invocation.
      *
-     * @param other {@code IntSupplier} who's result is returned if there is no
-     * value present.
-     * @return the value if present otherwise return result of {@code other}.
-     * @throws NullPointerException if value is absent and {@code other} is null.
+     * @param other a {@code IntSupplier} whose result is returned if no value
+     * is present
+     * @return the value if present otherwise the result of {@code other.getAsInt()}
+     * @throws NullPointerException if value is not present and {@code other} is
+     * null
      */
     public int orElseGet(IntSupplier other) {
         return isPresent ? value : other.getAsInt();
@@ -163,15 +165,19 @@
      * Return the contained value, if present, otherwise throw an exception
      * to be created by the provided supplier.
      *
-     * @param <V> Type of the exception to be thrown.
+     * @apiNote A method reference to the exception constructor with an empty
+     * argument list can be used as the supplier. For example,
+     * {@code IllegalStateException::new}
+     *
+     * @param <X> Type of the exception to be thrown
      * @param exceptionSupplier The supplier which will return the exception to
-     * be thrown.
-     * @return the value.
-     * @throws V if there is no value present.
-     * @throws NullPointerException if value is absent and
-     * {@code exceptionSupplier} is null.
+     * be thrown
+     * @return the present value
+     * @throws X if there is no value present
+     * @throws NullPointerException if no value is present and
+     * {@code exceptionSupplier} is null
      */
-    public<V extends Throwable> int orElseThrow(Supplier<V> exceptionSupplier) throws V {
+    public<X extends Throwable> int orElseThrow(Supplier<X> exceptionSupplier) throws X {
         if (isPresent) {
             return value;
         } else {
@@ -179,29 +185,61 @@
         }
     }
 
+    /**
+     * Indicates whether some other object is "equal to" this Optional. The
+     * other object is considered equal if:
+     * <ul>
+     * <li>it is also an {@code OptionalInt} and;
+     * <li>both instances have no value present or;
+     * <li>the present values are "equal to" each other via {@code ==}.
+     * </ul>
+     *
+     * @param obj an object to be tested for equality
+     * @return {code true} if the other object is "equal to" this object
+     * otherwise {@code false}
+     */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object obj) {
+        if (this == obj) {
             return true;
         }
 
-        if (!(o instanceof OptionalInt)) {
+        if (!(obj instanceof OptionalInt)) {
             return false;
         }
 
-        OptionalInt other = (OptionalInt) o;
-        return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent;
+        OptionalInt other = (OptionalInt) obj;
+        return (isPresent && other.isPresent)
+			? value == other.value
+			: isPresent == other.isPresent;
     }
 
+    /**
+     * Returns the hash code value of the present value, if any, or 0 (zero) if
+     * no value is present.
+     *
+     * @return hash code value of the present value or 0 if no value is present
+     */
     @Override
     public int hashCode() {
         return Integer.hashCode(value);
     }
 
+    /**
+     * Returns a non-empty string representation of this OptionalInt suitable for
+     * debugging. The exact presentation format is unspecified and may vary
+     * between implementations and versions.
+     *
+     * @implSpec If a value is present the result must include its string
+     * representation in the result. Empty and present OptionalInts must be
+     * unambiguously differentiable.
+     *
+     * @return the string representation of this instance
+     */
     @Override
     public String toString() {
         return isPresent
-			? String.format("IntOptional[%s]", value)
-			: "IntOptional.empty";
+			? String.format("OptionalInt[%s]", value)
+			: "OptionalInt.empty";
     }
 }
--- a/src/share/classes/java/util/OptionalLong.java	Fri Mar 08 08:26:36 2013 -0800
+++ b/src/share/classes/java/util/OptionalLong.java	Fri Mar 08 08:26:46 2013 -0800
@@ -34,10 +34,10 @@
  * {@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(java.lang.Object) orElse()}
+ * value are provided, such as {@link #orElse(long) orElse()}
  * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (execute a block
- * of code if the value is present.)
+ * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (execute a block
+ * of code if the value is present).
  *
  * @since 1.8
  */
@@ -45,7 +45,7 @@
     /**
      * Common instance for {@code empty()}.
      */
-    private final static OptionalLong EMPTY = new OptionalLong();
+    private static final OptionalLong EMPTY = new OptionalLong();
 
     /**
      * If true then the value is present, otherwise indicates no value is present
@@ -54,16 +54,6 @@
     private final long value;
 
     /**
-     * Construct a non-empty instance
-     *
-     * @param value the long value to be present.
-     */
-    private OptionalLong(long value) {
-        this.isPresent = true;
-        this.value = value;
-    }
-
-    /**
      * Construct an empty instance.
      *
      * @implNote generally only one empty instance, {@link OptionalLong#EMPTY},
@@ -75,24 +65,35 @@
     }
 
     /**
-     * Return an empty {@code OptionalLong}.  No value is present for this Optional.
+     * Returns an empty {@code OptionalLong} instance.  No value is present for this
+	 * OptionalLong.
      *
      * @apiNote Though it may be tempting to do so, avoid testing if an object
-     * is empty by comparing with {@code ==} against instances returned
+     * is empty by comparing with {@code ==} against instances returned by
      * {@code Option.empty()}. There is no guarantee that it is a singleton.
-     * Instead, use {@code isPresent()}.
+     * Instead, use {@link #isPresent()}.
      *
      *  @return an empty {@code OptionalLong}.
      */
-    @SuppressWarnings("unchecked")
     public static OptionalLong empty() {
         return EMPTY;
     }
 
     /**
-     * Create a new {@code OptionalLong} with a present value
-     * @param value The long value
-     * @param value new {@code OptionalLong} with a present value.
+     * Construct an instance with the value present.
+     *
+     * @param value the long value to be present
+     */
+    private OptionalLong(long value) {
+        this.isPresent = true;
+        this.value = value;
+    }
+
+    /**
+     * Return an {@code OptionalLong} with the specified value present.
+     *
+     * @param value the value to be present
+     * @return an {@code OptionalLong} with the value present
      */
     public static OptionalLong of(long value) {
         return new OptionalLong(value);
@@ -102,8 +103,8 @@
      * If a value is present in this {@code OptionalLong}, returns the value,
      * otherwise throws {@code NoSuchElementException}.
      *
-     * @return the value held by this {@code OptionalLong}.
-     * @throws NoSuchElementException if there is no value present.
+     * @return the value held by this {@code OptionalLong}
+     * @throws NoSuchElementException if there is no value present
      *
      * @see OptionalLong#isPresent()
      */
@@ -117,19 +118,19 @@
     /**
      * Return {@code true} if there is a value present, otherwise {@code false}.
      *
-     * @return {@code true} if there is a value present, otherwise {@code false}.
+     * @return {@code true} if there is a value present, otherwise {@code false}
      */
     public boolean isPresent() {
         return isPresent;
     }
 
     /**
-     * Execute the specified consumer with the value if a value is present,
+     * Have the specified consumer accept the value if a value is present,
      * otherwise do nothing.
      *
-     * @param consumer block to be executed if a value is present.
+     * @param consumer block to be executed if a value is present
      * @throws NullPointerException if value is present and {@code consumer} is
-     * null.
+     * null
      */
     public void ifPresent(LongConsumer consumer) {
         if (isPresent)
@@ -139,8 +140,8 @@
     /**
      * Return the value if present, otherwise return {@code other}.
      *
-     * @param other value to be returned if there is no value present.
-     * @return the value, if present, otherwise {@code other}.
+     * @param other the value to be returned if there is no value present
+     * @return the value, if present, otherwise {@code other}
      */
     public long orElse(long other) {
         return isPresent ? value : other;
@@ -150,10 +151,11 @@
      * Return the value if present, otherwise invoke {@code other} and return
      * the result of that invocation.
      *
-     * @param other {@code LongSupplier} who's result is returned if there is no
-     * value present.
-     * @return the value if present otherwise return result of {@code other}.
-     * @throws NullPointerException if value is absent and {@code other} is null.
+     * @param other a {@code LongSupplier} whose result is returned if no value
+     * is present
+     * @return the value if present otherwise the result of {@code other.getAsLong()}
+     * @throws NullPointerException if value is not present and {@code other} is
+     * null
      */
     public long orElseGet(LongSupplier other) {
         return isPresent ? value : other.getAsLong();
@@ -163,15 +165,19 @@
      * Return the contained value, if present, otherwise throw an exception
      * to be created by the provided supplier.
      *
-     * @param <V> Type of the exception to be thrown.
+     * @apiNote A method reference to the exception constructor with an empty
+     * argument list can be used as the supplier. For example,
+     * {@code IllegalStateException::new}
+     *
+     * @param <X> Type of the exception to be thrown
      * @param exceptionSupplier The supplier which will return the exception to
-     * be thrown.
-     * @return the value.
-     * @throws V if there is no value present.
-     * @throws NullPointerException if value is absent and
-     * {@code exceptionSupplier} is null.
+     * be thrown
+     * @return the present value
+     * @throws X if there is no value present
+     * @throws NullPointerException if no value is present and
+     * {@code exceptionSupplier} is null
      */
-    public<V extends Throwable> long orElseThrow(Supplier<V> exceptionSupplier) throws V {
+    public<X extends Throwable> long orElseThrow(Supplier<X> exceptionSupplier) throws X {
         if (isPresent) {
             return value;
         } else {
@@ -179,29 +185,61 @@
         }
     }
 
+    /**
+     * Indicates whether some other object is "equal to" this Optional. The
+     * other object is considered equal if:
+     * <ul>
+     * <li>it is also an {@code OptionalInt} and;
+     * <li>both instances have no value present or;
+     * <li>the present values are "equal to" each other via {@code ==}.
+     * </ul>
+     *
+     * @param obj an object to be tested for equality
+     * @return {code true} if the other object is "equal to" this object
+     * otherwise {@code false}
+     */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) {
+    public boolean equals(Object obj) {
+        if (this == obj) {
             return true;
         }
 
-        if (!(o instanceof OptionalLong)) {
+        if (!(obj instanceof OptionalLong)) {
             return false;
         }
 
-        OptionalLong other = (OptionalLong) o;
-        return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent;
+        OptionalLong other = (OptionalLong) obj;
+        return (isPresent && other.isPresent)
+			? value == other.value
+			: isPresent == other.isPresent;
     }
 
+    /**
+     * Returns the hash code value of the present value, if any, or 0 (zero) if
+     * no value is present.
+     *
+     * @return hash code value of the present value or 0 if no value is present
+     */
     @Override
     public int hashCode() {
         return Long.hashCode(value);
     }
 
+    /**
+     * Returns a non-empty string representation of this OptionalLong suitable for
+     * debugging. The exact presentation format is unspecified and may vary
+     * between implementations and versions.
+     *
+     * @implSpec If a value is present the result must include its string
+     * representation in the result. Empty and present OptionalLongs must be
+     * unambiguously differentiable.
+     *
+     * @return the string representation of this instance
+     */
     @Override
     public String toString() {
         return isPresent
-			? String.format("LongOptional[%s]", value)
-			: "LongOptional.empty";
+			? String.format("OptionalLong[%s]", value)
+			: "OptionalLong.empty";
     }
 }