diff --git a/jdk/src/java.base/share/classes/java/util/Optional.java b/jdk/src/java.base/share/classes/java/util/Optional.java index cc5c1309663..514632b5ccc 100644 --- a/jdk/src/java.base/share/classes/java/util/Optional.java +++ b/jdk/src/java.base/share/classes/java/util/Optional.java @@ -31,21 +31,22 @@ import java.util.function.Supplier; import java.util.stream.Stream; /** - * A container object which may or may not contain a non-null value. - * If a value is present, {@code isPresent()} will return {@code true} and - * {@code get()} will return the value. + * A container object which may or may not contain a non-{@code null} value. + * If a value is present, {@code isPresent()} returns {@code true} and + * {@code get()} returns the value. * *
Additional methods that depend on the presence or absence of a contained * value are provided, such as {@link #orElse(java.lang.Object) orElse()} - * (return a default value if value not present) and - * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (perform an - * action if the value is present). + * (returns a default value if no value is present) and + * {@link #ifPresent(java.util.function.Consumer) ifPresent()} (performs an + * action if a value is present). * *
This is a value-based
* class; use of identity-sensitive operations (including reference equality
* ({@code ==}), identity hash code, or synchronization) on instances of
* {@code Optional} may have unpredictable results and should be avoided.
*
+ * @param If the mapping function returns a {@code null} result then this method
+ * returns an empty {@code Optional}.
+ *
+ * @apiNote
+ * This method supports post-processing on {@code Optional} values, without
* the need to explicitly check for a return status. For example, the
- * following code traverses a stream of file names, selects one that has
- * not yet been processed, and then opens that file, returning an
+ * following code traverses a stream of file names, selects one that has not
+ * yet been processed, and then opens that file, returning an
* {@code Optional This method is similar to {@link #map(Function)}, but the mapping
+ * function is one whose result is already an {@code Optional}, and if
+ * invoked, {@code flatMap} does not wrap it within an additional
* {@code Optional}.
*
- * @param The type parameter to the {@code Optional} returned by
- * @param mapper a mapping function to apply to the value, if present
- * the mapping function
+ * @param The type of value of the {@code Optional} returned by the
+ * mapping function
+ * @param mapper the mapping function to apply to a value, if present
* @return the result of applying an {@code Optional}-bearing mapping
- * function to the value of this {@code Optional}, if a value is present,
- * otherwise an empty {@code Optional}
- * @throws NullPointerException if the mapping function is null or returns
- * a null result
+ * function to the value of this {@code Optional}, if a value is
+ * present, otherwise an empty {@code Optional}
+ * @throws NullPointerException if the mapping function is {@code null} or
+ * returns a {@code null} result
*/
public Optional flatMap(Function super T, Optional> mapper) {
Objects.requireNonNull(mapper);
@@ -265,19 +274,41 @@ public final class Optional 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()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.DoubleConsumer) ifPresent()} (performs
+ * an action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,12 +71,13 @@ public final class OptionalDouble {
}
/**
- * Returns an empty {@code OptionalDouble} instance. No value is present for this
- * OptionalDouble.
+ * Returns an empty {@code OptionalDouble} instance. No value is present
+ * for this {@code OptionalDouble}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalDouble.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
* @return an empty {@code OptionalDouble}.
@@ -86,9 +87,9 @@ public final class OptionalDouble {
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the double value to be present.
+ * @param value the double value to describe.
*/
private OptionalDouble(double value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalDouble {
}
/**
- * Return an {@code OptionalDouble} with the specified value present.
+ * Returns an {@code OptionalDouble} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalDouble} with the value present
*/
public static OptionalDouble of(double value) {
@@ -106,12 +107,11 @@ public final class OptionalDouble {
}
/**
- * 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
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalDouble}
+ * @throws NoSuchElementException if no value is present
* @see OptionalDouble#isPresent()
*/
public double getAsDouble() {
@@ -122,21 +122,21 @@ public final class OptionalDouble {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if a value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(DoubleConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalDouble {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(DoubleConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,20 @@ public final class OptionalDouble {
}
/**
- * If a value is present return a sequential {@link DoubleStream} containing
- * only that value, otherwise return an empty {@code DoubleStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional doubles to a {@code DoubleStream} of present doubles:
+ * If a value is present, returns a sequential {@link DoubleStream}
+ * containing only that value, otherwise returns an empty
+ * {@code DoubleStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional doubles
+ * to a {@code DoubleStream} of present doubles:
* Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(int) orElse()}
- * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.IntConsumer) ifPresent()} (performs an
+ * action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,24 +71,25 @@ public final class OptionalInt {
}
/**
- * Returns an empty {@code OptionalInt} instance. No value is present for this
- * OptionalInt.
+ * Returns an empty {@code OptionalInt} instance. No value is present for
+ * this {@code OptionalInt}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalInt.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
- * @return an empty {@code OptionalInt}
+ * @return an empty {@code OptionalInt}
*/
public static OptionalInt empty() {
return EMPTY;
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the int value to be present
+ * @param value the int value to describe
*/
private OptionalInt(int value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalInt {
}
/**
- * Return an {@code OptionalInt} with the specified value present.
+ * Returns an {@code OptionalInt} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalInt} with the value present
*/
public static OptionalInt of(int value) {
@@ -106,12 +107,11 @@ public final class OptionalInt {
}
/**
- * 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
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalInt}
+ * @throws NoSuchElementException if no value is present
* @see OptionalInt#isPresent()
*/
public int getAsInt() {
@@ -122,21 +122,21 @@ public final class OptionalInt {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(IntConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalInt {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(IntConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,19 @@ public final class OptionalInt {
}
/**
- * If a value is present return a sequential {@link IntStream} containing
- * only that value, otherwise return an empty {@code IntStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional integers to an {@code IntStream} of present integers:
+ * If a value is present, returns a sequential {@link IntStream} containing
+ * only that value, otherwise returns an empty {@code IntStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional
+ * integers to an {@code IntStream} of present integers:
* Additional methods that depend on the presence or absence of a contained
* value are provided, such as {@link #orElse(long) orElse()}
- * (return a default value if value not present) and
- * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (perform an
- * action if the value is present).
+ * (returns a default value if no value is present) and
+ * {@link #ifPresent(java.util.function.LongConsumer) ifPresent()} (performs an
+ * action if a value is present).
*
* This is a value-based
* class; use of identity-sensitive operations (including reference equality
@@ -71,24 +71,25 @@ public final class OptionalLong {
}
/**
- * Returns an empty {@code OptionalLong} instance. No value is present for this
- * OptionalLong.
+ * Returns an empty {@code OptionalLong} instance. No value is present for
+ * this {@code OptionalLong}.
*
- * @apiNote Though it may be tempting to do so, avoid testing if an object
- * is empty by comparing with {@code ==} against instances returned by
- * {@code Option.empty()}. There is no guarantee that it is a singleton.
+ * @apiNote
+ * Though it may be tempting to do so, avoid testing if an object is empty
+ * by comparing with {@code ==} against instances returned by
+ * {@code OptionalLong.empty()}. There is no guarantee that it is a singleton.
* Instead, use {@link #isPresent()}.
*
- * @return an empty {@code OptionalLong}.
+ * @return an empty {@code OptionalLong}.
*/
public static OptionalLong empty() {
return EMPTY;
}
/**
- * Construct an instance with the value present.
+ * Construct an instance with the described value.
*
- * @param value the long value to be present
+ * @param value the long value to describe
*/
private OptionalLong(long value) {
this.isPresent = true;
@@ -96,9 +97,9 @@ public final class OptionalLong {
}
/**
- * Return an {@code OptionalLong} with the specified value present.
+ * Returns an {@code OptionalLong} describing the given value.
*
- * @param value the value to be present
+ * @param value the value to describe
* @return an {@code OptionalLong} with the value present
*/
public static OptionalLong of(long value) {
@@ -106,12 +107,11 @@ public final class OptionalLong {
}
/**
- * 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
+ * If a value is present, returns the value, otherwise throws
+ * {@code NoSuchElementException}.
*
+ * @return the value described by this {@code OptionalLong}
+ * @throws NoSuchElementException if no value is present
* @see OptionalLong#isPresent()
*/
public long getAsLong() {
@@ -122,21 +122,21 @@ public final class OptionalLong {
}
/**
- * Return {@code true} if there is a value present, otherwise {@code false}.
+ * If a value is present, returns {@code true}, otherwise {@code false}.
*
- * @return {@code true} if there is a value present, otherwise {@code false}
+ * @return {@code true} if a value is present, otherwise {@code false}
*/
public boolean isPresent() {
return isPresent;
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise do nothing.
+ * If a value is present, performs the given action with the value,
+ * otherwise does nothing.
*
- * @param action the action to be performed if a value is present
- * @throws NullPointerException if a value is present and {@code action} is
- * null
+ * @param action the action to be performed, if a value is present
+ * @throws NullPointerException if value is present and the given action is
+ * {@code null}
*/
public void ifPresent(LongConsumer action) {
if (isPresent) {
@@ -145,15 +145,16 @@ public final class OptionalLong {
}
/**
- * If a value is present, perform the given action with the value,
- * otherwise perform the given empty-based action.
+ * If a value is present, performs the given action with the value,
+ * otherwise performs the given empty-based action.
*
- * @param action the action to be performed if a value is present
- * @param emptyAction the empty-based action to be performed if a value is
- * not present
- * @throws NullPointerException if a value is present and {@code action} is
- * null, or a value is not present and {@code emptyAction} is null.
- * @since 1.9
+ * @param action the action to be performed, if a value is present
+ * @param emptyAction the empty-based action to be performed, if no value is
+ * present
+ * @throws NullPointerException if a value is present and the given action
+ * is {@code null}, or no value is present and the given empty-based
+ * action is {@code null}.
+ * @since 9
*/
public void ifPresentOrElse(LongConsumer action, Runnable emptyAction) {
if (isPresent) {
@@ -164,19 +165,19 @@ public final class OptionalLong {
}
/**
- * If a value is present return a sequential {@link LongStream} containing
- * only that value, otherwise return an empty {@code LongStream}.
- *
- * @apiNote This method can be used to transform a {@code Stream} of
- * optional longs to a {@code LongStream} of present longs:
+ * If a value is present, returns a sequential {@link LongStream} containing
+ * only that value, otherwise returns an empty {@code LongStream}.
*
+ * @apiNote
+ * This method can be used to transform a {@code Stream} of optional longs
+ * to an {@code LongStream} of present longs:
* {@code
@@ -222,12 +229,12 @@ public final class Optional{@code
* Stream
*
* @return the optional value as a {@code Stream}
- * @since 1.9
+ * @since 9
*/
public Stream
*
{@code
* Stream
*
* @return the optional value as a {@code DoubleStream}
- * @since 1.9
+ * @since 9
*/
public DoubleStream stream() {
if (isPresent) {
@@ -187,9 +189,10 @@ public final class OptionalDouble {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public double orElse(double other) {
@@ -197,34 +200,35 @@ public final class OptionalDouble {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @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
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public double orElseGet(DoubleSupplier other) {
- return isPresent ? value : other.getAsDouble();
+ public double orElseGet(DoubleSupplier supplier) {
+ return isPresent ? value : supplier.getAsDouble();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @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
*
*
* @param obj an object to be tested for equality
* @return {@code true} if the other object is "equal to" this object
- * otherwise {@code false}
+ * otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
@@ -264,10 +269,11 @@ public final class OptionalDouble {
}
/**
- * Returns the hash code value of the present value, if any, or 0 (zero) if
- * no value is present.
+ * Returns the hash code of the value, if present, otherwise {@code 0}
+ * (zero) if no value is present.
*
- * @return hash code value of the present value or 0 if no value is present
+ * @return hash code value of the present value or {@code 0} if no value is
+ * present
*/
@Override
public int hashCode() {
@@ -275,14 +281,13 @@ public final class OptionalDouble {
}
/**
- * {@inheritDoc}
+ * Returns a non-empty string representation of this {@code OptionalDouble}
+ * suitable for debugging. The exact presentation format is unspecified and
+ * may vary between implementations and versions.
*
- * Returns a non-empty string representation of this object 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 instances must be
+ * @implSpec
+ * If a value is present the result must include its string representation
+ * in the result. Empty and present {@code OptionalDouble}s must be
* unambiguously differentiable.
*
* @return the string representation of this instance
diff --git a/jdk/src/java.base/share/classes/java/util/OptionalInt.java b/jdk/src/java.base/share/classes/java/util/OptionalInt.java
index 92a1d855be8..cc56f47e4ba 100644
--- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java
+++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.java
@@ -30,15 +30,15 @@ import java.util.function.Supplier;
import java.util.stream.IntStream;
/**
- * A container object which may or may not contain a {@code int} value.
- * If a value is present, {@code isPresent()} will return {@code true} and
- * {@code getAsInt()} will return the value.
+ * A container object which may or may not contain an {@code int} value. If a
+ * value is present, {@code isPresent()} returns {@code true} and
+ * {@code getAsInt()} returns the value.
*
* {@code
* Stream
*
* @return the optional value as an {@code IntStream}
- * @since 1.9
+ * @since 9
*/
public IntStream stream() {
if (isPresent) {
@@ -187,9 +188,10 @@ public final class OptionalInt {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public int orElse(int other) {
@@ -197,34 +199,35 @@ public final class OptionalInt {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @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
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public int orElseGet(IntSupplier other) {
- return isPresent ? value : other.getAsInt();
+ public int orElseGet(IntSupplier supplier) {
+ return isPresent ? value : supplier.getAsInt();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @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
*
{@code
* Stream
*
- * @return the optional value as a {@code LongStream}
- * @since 1.9
+ * @return the optional value as an {@code LongStream}
+ * @since 9
*/
public LongStream stream() {
if (isPresent) {
@@ -187,9 +188,10 @@ public final class OptionalLong {
}
/**
- * Return the value if present, otherwise return {@code other}.
+ * If a value is present, returns the value, otherwise returns
+ * {@code other}.
*
- * @param other the value to be returned if there is no value present
+ * @param other the value to be returned, if no value is present
* @return the value, if present, otherwise {@code other}
*/
public long orElse(long other) {
@@ -197,34 +199,35 @@ public final class OptionalLong {
}
/**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
+ * If a value is present, returns the value, otherwise returns the result
+ * produced by the supplying function.
*
- * @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
+ * @param supplier the supplying function that produces a value to be returned
+ * @return the value, if present, otherwise the result produced by the
+ * supplying function
+ * @throws NullPointerException if no value is present and the supplying
+ * function is {@code null}
*/
- public long orElseGet(LongSupplier other) {
- return isPresent ? value : other.getAsLong();
+ public long orElseGet(LongSupplier supplier) {
+ return isPresent ? value : supplier.getAsLong();
}
/**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
+ * If a value is present, returns the value, otherwise throws an exception
+ * produced by the exception supplying function.
*
- * @apiNote A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
+ * @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
*