/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { LongConsumer } from "../function/LongConsumer"; import type { LongSupplier } from "../function/LongSupplier"; import type { Supplier } from "../function/Supplier"; import type { Object } from "../../lang/Object"; import type { String } from "../../lang/String"; /** * A container object which may or may not contain a {@code long} value. * If a value is present, {@code isPresent()} will return {@code true} and * {@code getAsLong()} will return the value. * *
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()} (execute a block * of code if the 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 OptionalLong} may have unpredictable results and should be avoided.
* @since 1.8
*/
export type OptionalLong = Object & {
/**
* 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
* @see OptionalLong#isPresent()
*/
getAsLong(): number;
/**
* Return {@code true} if there is a value present, otherwise {@code false}.
* @return {@code true} if there is a value present, otherwise {@code false}
*/
isPresent(): boolean;
/**
* 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
* @throws NullPointerException if value is present and {@code consumer} is
null
*/
ifPresent(consumer: LongConsumer): void;
/**
* Return the value if present, otherwise return {@code other}.
* @param other the value to be returned if there is no value present
* @return the value, if present, otherwise {@code other}
*/
orElse(other: number): number;
/**
* Return the value if present, otherwise invoke {@code other} and return
* the result of that invocation.
* @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
*/
orElseGet(other: LongSupplier): number;
/**
* Return the contained value, if present, otherwise throw an exception
* to be created by the provided supplier.
* @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}
*/
equals(obj: unknown): boolean;
/**
* 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
*/
hashCode(): number;
/**
* {@inheritDoc}
*
* 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
unambiguously differentiable.
* @return the string representation of this instance
*/
toString(): string;
};