OptionalDouble
Defined in: src/stream/Optional.ts:356
An optional number returned by DoubleStream operations and average(). Immutable.
Extends
Section titled “Extends”NumberOptional
Methods
Section titled “Methods”[INSPECT]()
Section titled “[INSPECT]()”[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.
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”NumberOptional.[INSPECT]
equals()
Section titled “equals()”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.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”NumberOptional.equals
getAsDouble()
Section titled “getAsDouble()”getAsDouble():
number
Defined in: src/stream/Optional.ts:375
Returns the value.
Returns
Section titled “Returns”number
Throws
Section titled “Throws”NoSuchElementException (“No value present”) if empty
hashCode()
Section titled “hashCode()”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.
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”NumberOptional.hashCode
ifPresent()
Section titled “ifPresent()”ifPresent(
action):void
Defined in: src/stream/Optional.ts:80
Calls action with the value if one is present; otherwise does nothing.
Parameters
Section titled “Parameters”action
Section titled “action”(value) => void
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if a value is present and action is null
Inherited from
Section titled “Inherited from”NumberOptional.ifPresent
ifPresentOrElse()
Section titled “ifPresentOrElse()”ifPresentOrElse(
action,emptyAction):void
Defined in: src/stream/Optional.ts:88
Calls action with the value if one is present, otherwise calls emptyAction.
Parameters
Section titled “Parameters”action
Section titled “action”(value) => void
emptyAction
Section titled “emptyAction”() => void
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if the function that would be called is null
Inherited from
Section titled “Inherited from”NumberOptional.ifPresentOrElse
isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/stream/Optional.ts:72
Returns true if no value is present.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”NumberOptional.isEmpty
isPresent()
Section titled “isPresent()”isPresent():
boolean
Defined in: src/stream/Optional.ts:67
Returns true if a value is present.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”NumberOptional.isPresent
orElse()
Section titled “orElse()”Call Signature
Section titled “Call Signature”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).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
Inherited from
Section titled “Inherited from”NumberOptional.orElse
Call Signature
Section titled “Call Signature”orElse(
other):number|null
Defined in: src/stream/Optional.ts:96
Returns the value if present, otherwise other; a null fallback gives T | null.
Parameters
Section titled “Parameters”number | null
Returns
Section titled “Returns”number | null
Inherited from
Section titled “Inherited from”NumberOptional.orElse
orElseGet()
Section titled “orElseGet()”Call Signature
Section titled “Call Signature”orElseGet(
supplier):number
Defined in: src/stream/Optional.ts:105
Returns the value if present, otherwise supplier() (called only when empty).
Parameters
Section titled “Parameters”supplier
Section titled “supplier”() => number
Returns
Section titled “Returns”number
Throws
Section titled “Throws”NullPointerException if empty and supplier is null
Inherited from
Section titled “Inherited from”NumberOptional.orElseGet
Call Signature
Section titled “Call Signature”orElseGet(
supplier):number|null
Defined in: src/stream/Optional.ts:110
Returns the value if present, otherwise supplier(), which may return null.
Parameters
Section titled “Parameters”supplier
Section titled “supplier”() => number | null
Returns
Section titled “Returns”number | null
Throws
Section titled “Throws”NullPointerException if empty and supplier is null
Inherited from
Section titled “Inherited from”NumberOptional.orElseGet
orElseThrow()
Section titled “orElseThrow()”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.
Parameters
Section titled “Parameters”exceptionSupplier?
Section titled “exceptionSupplier?”() => unknown
Returns
Section titled “Returns”number
Throws
Section titled “Throws”NoSuchElementException if empty and no supplier is given
Throws
Section titled “Throws”NullPointerException if empty and the supplier, or the error it returns, is null
Inherited from
Section titled “Inherited from”NumberOptional.orElseThrow
stream()
Section titled “stream()”stream():
DoubleStream
Defined in: src/stream/Optional.ts:379
Returns an DoubleStream of the value, or an empty stream.
Returns
Section titled “Returns”DoubleStream
toString()
Section titled “toString()”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).
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”NumberOptional.toString
empty()
Section titled “empty()”
staticempty():OptionalDouble
Defined in: src/stream/Optional.ts:364
Returns the empty optional (a shared instance).
Returns
Section titled “Returns”OptionalDouble
staticof(value):OptionalDouble
Defined in: src/stream/Optional.ts:368
Returns an optional holding value.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”OptionalDouble