OptionalLong (Groovy JDK enhancements)

Package: java.util

## Class OptionalLong

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `OptionalLong` | `filter(LongPredicate test)` If a value is present in the `OptionalLong`, tests the value using the given predicate and returns the optional if the test returns true or else empty.
    `long` | `get()` If a value is present in the `OptionalLong`, returns the value, otherwise throws `NoSuchElementException`.
    `Optional` | `mapToObj(LongFunction mapper)` If a value is present in the `OptionalLong`, returns an `Optional` consisting of the result of applying the given function to the value or else empty.
    `LongStream` | `stream()` If a value is present in the OptionalLong, returns a LongStream with the value as its source or else an empty stream.

  - #### Methods inherited from class java.lang.Object

    `addShutdownHook`, `any`, `any`, `asBoolean`, `asType`, `collect`, `collect`, `collect`, `dump`, `each`, `eachMatch`, `eachMatch`, `eachWithIndex`, `every`, `every`, `find`, `find`, `findAll`, `findAll`, `findIndexOf`, `findIndexOf`, `findIndexValues`, `findIndexValues`, `findLastIndexOf`, `findLastIndexOf`, `findResult`, `findResult`, `getAt`, `getMetaClass`, `getMetaPropertyValues`, `getProperties`, `grep`, `grep`, `hasProperty`, `identity`, `inject`, `inject`, `inspect`, `invokeMethod`, `is`, `isCase`, `iterator`, `metaClass`, `print`, `print`, `printf`, `printf`, `println`, `println`, `println`, `putAt`, `respondsTo`, `respondsTo`, `setMetaClass`, `split`, `sprintf`, `sprintf`, `stream`, `tap`, `toString`, `use`, `use`, `use`, `with`, `with`, `withCloseable`, `withStream`, `withTraits`

- - ### Methods Detail

    - #### public OptionalLong filter(LongPredicate test)

      If a value is present in the `OptionalLong`, tests the value using the given predicate and returns the optional if the test returns true or else empty.

          assert !OptionalLong.empty().filter(n -> true).isPresent()
          assert  OptionalLong.of(123L).filter(n -> true).isPresent()
          assert !OptionalLong.of(123L).filter(n -> false).isPresent()
          assert  OptionalLong.of(123L).filter(n -> true).getAsLong() == 123L

      Parameters:
      Since:
        3.0.0

    - #### public long get()

      If a value is present in the `OptionalLong`, returns the value, otherwise throws `NoSuchElementException`.

          assert OptionalLong.of(1234L).get() == 1234L

      Since:
        3.0.0

    - #### public Optional mapToObj(LongFunction mapper)

      If a value is present in the `OptionalLong`, returns an `Optional` consisting of the result of applying the given function to the value or else empty.

          assert !OptionalLong.empty().mapToObj(x -> new Object()).isPresent()
          assert  OptionalLong.of(123L).mapToObj(x -> new Object()).isPresent()
          assert !OptionalLong.of(123L).mapToObj(x -> null).isPresent()
          assert  OptionalLong.of(1234L).mapToObj(Long::toString).get() == '1234'

      Parameters:
      Since:
        3.0.0

    - #### public LongStream stream()

      If a value is present in the OptionalLong, returns a LongStream with the value as its source or else an empty stream.

      Since:
        3.0.0