Class Optional<T>

A container object which may or may not contain a non-null value.

Type Parameters

  • T

    the type of the value

Hierarchy

  • Optional

Constructors

Properties

value: T

Methods

  • Returns the value if present or empty optional throws NoSuchElementException.

    Returns T

  • Performs the given action with the value, otherwise does nothing.

    Parameters

    • action: ((value) => void)

      the action to be performed

        • (value): void
        • Parameters

          • value: T

          Returns void

    Returns void

    Throws

    NullPointerException if given action is null

  • Performs the given action with the value, otherwise performs the given empty-based action.

    Parameters

    • action: ((value) => void)

      the action to be performed if value is present

        • (value): void
        • Parameters

          • value: T

          Returns void

    • emptyAction: (() => void)

      the empty-based action to be performed if value is absent

        • (): void
        • Returns void

    Returns void

    Throws

    NullPointerException if value is present and the given action is null, or value is absent and the given empty-based action is null

  • Returns the value if present or else returns other value.

    Parameters

    • otherValue: T

      the value to be returned if value is absent

    Returns T

  • Returns the value if present or empty optional throws NoSuchElementException.

    Returns T

  • Returns an optional of given non-null value.

    Type Parameters

    • T

      the type of the value

    Parameters

    • value: T

      the value to describe

    Returns Optional<Exclude<T, undefined>>

    Throws

    NullPointerException if value is null

  • Returns an optional of given non-null value, otherwise an empty optional.

    Type Parameters

    • T

    Parameters

    • value: T

    Returns Optional<Exclude<T, undefined>>

Generated using TypeDoc