Skip to content
Buy me a coffee

OptionalDouble

Defined in: src/stream/Optional.ts:356

An optional number returned by DoubleStream operations and average(). Immutable.

  • NumberOptional

[INSPECT](): string

Defined in: src/stream/Optional.ts:128

Returns toString(), so Node’s console.log and util.inspect print the optional the same way.

string

NumberOptional.[INSPECT]


equals(o): boolean

Defined in: src/stream/Optional.ts:261

Returns true if o is the same kind of number optional and both are empty or both hold the same number. For OptionalDouble, NaN equals NaN and -0 differs from 0.

unknown

boolean

NumberOptional.equals


getAsDouble(): number

Defined in: src/stream/Optional.ts:375

Returns the value.

number

NoSuchElementException (“No value present”) if empty


hashCode(): number

Defined in: src/stream/Optional.ts:268

Returns the hash code the reference gives the boxed value (int, long or double hash); 0 when empty.

number

NumberOptional.hashCode


ifPresent(action): void

Defined in: src/stream/Optional.ts:80

Calls action with the value if one is present; otherwise does nothing.

(value) => void

void

NullPointerException if a value is present and action is null

NumberOptional.ifPresent


ifPresentOrElse(action, emptyAction): void

Defined in: src/stream/Optional.ts:88

Calls action with the value if one is present, otherwise calls emptyAction.

(value) => void

() => void

void

NullPointerException if the function that would be called is null

NumberOptional.ifPresentOrElse


isEmpty(): boolean

Defined in: src/stream/Optional.ts:72

Returns true if no value is present.

boolean

NumberOptional.isEmpty


isPresent(): boolean

Defined in: src/stream/Optional.ts:67

Returns true if a value is present.

boolean

NumberOptional.isPresent


orElse(other): number

Defined in: src/stream/Optional.ts:94

Returns the value if present, otherwise other (evaluated eagerly, even when a value is present).

number

number

NumberOptional.orElse

orElse(other): number | null

Defined in: src/stream/Optional.ts:96

Returns the value if present, otherwise other; a null fallback gives T | null.

number | null

number | null

NumberOptional.orElse


orElseGet(supplier): number

Defined in: src/stream/Optional.ts:105

Returns the value if present, otherwise supplier() (called only when empty).

() => number

number

NullPointerException if empty and supplier is null

NumberOptional.orElseGet

orElseGet(supplier): number | null

Defined in: src/stream/Optional.ts:110

Returns the value if present, otherwise supplier(), which may return null.

() => number | null

number | null

NullPointerException if empty and supplier is null

NumberOptional.orElseGet


orElseThrow(exceptionSupplier?): number

Defined in: src/stream/Optional.ts:121

Returns the value if present; otherwise throws NoSuchElementException (“No value present”) without an argument, or the error exceptionSupplier() returns.

() => unknown

number

NoSuchElementException if empty and no supplier is given

NullPointerException if empty and the supplier, or the error it returns, is null

NumberOptional.orElseThrow


stream(): DoubleStream

Defined in: src/stream/Optional.ts:379

Returns an DoubleStream of the value, or an empty stream.

DoubleStream


toString(): string

Defined in: src/stream/Optional.ts:278

Returns OptionalInt[5] (and so on), or OptionalInt.empty; doubles print as the reference prints them (1.0, 1.0E21).

string

NumberOptional.toString


static empty(): OptionalDouble

Defined in: src/stream/Optional.ts:364

Returns the empty optional (a shared instance).

OptionalDouble


static of(value): OptionalDouble

Defined in: src/stream/Optional.ts:368

Returns an optional holding value.

number

OptionalDouble