OptionalLong (Java SE 26 & JDK 26)
-
Method Summary
empty()Returns an empty
OptionalLonginstance.booleanIndicates whether some other object is "equal to" this
OptionalLong.longIf a value is present, returns the value, otherwise throws
NoSuchElementException.inthashCode()Returns the hash code of the value, if present, otherwise
0(zero) if no value is present.voidIf a value is present, performs the given action with the value, otherwise does nothing.
voidIf a value is present, performs the given action with the value, otherwise performs the given empty-based action.
booleanisEmpty()If a value is not present, returns
true, otherwisefalse.booleanIf a value is present, returns
true, otherwisefalse.of(long value) Returns an
OptionalLongdescribing the given value.longorElse(long other) If a value is present, returns the value, otherwise returns
other.longIf a value is present, returns the value, otherwise returns the result produced by the supplying function.
longIf a value is present, returns the value, otherwise throws
NoSuchElementException.orElseThrow(Supplier<? extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.
stream()If a value is present, returns a sequential
LongStreamcontaining only that value, otherwise returns an emptyLongStream.toString()Returns a non-empty string representation of this
OptionalLongsuitable for debugging.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitCreates and returns a copy of this object.
protected voidDeprecated, for removal: This API element is subject to removal in a future version.
Returns the runtime class of this
Object.final voidWakes up a single thread that is waiting on this object's monitor.
final voidWakes up all threads that are waiting on this object's monitor.
final voidCauses the current thread to wait until it is awakened, typically by being notified or interrupted.
final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Method Details
-
empty
-
of
-
getAsLong
-
isPresent
-
isEmpty
-
ifPresent
-
ifPresentOrElse
-
stream
-
orElse
-
orElseGet
-
orElseThrow
-
orElseThrow
-
equals
-
hashCode
-
toString
-