Class LazyDelegatingOptional<T>

  • All Implemented Interfaces:
    Optional<T>
    Direct Known Subclasses:
    Conditional, First, Frozen, MapEntry, Next, Sieved

    public abstract class LazyDelegatingOptional<T>
    extends java.lang.Object
    implements Optional<T>
    An abstract Optional which delegates all method calls to another given Optional.

    This class is abstract and is meant to be a convenient way of composing Optionals despite the lack of native support for the decoration pattern in Java.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isPresent()
      Returns whether the optional value is present.
      T value()
      Returns the optional value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LazyDelegatingOptional

        protected LazyDelegatingOptional​(Single<Optional<T>> delegate)
    • Method Detail

      • isPresent

        public final boolean isPresent()
        Description copied from interface: Optional
        Returns whether the optional value is present.
        Specified by:
        isPresent in interface Optional<T>
      • value

        public final T value()
                      throws java.util.NoSuchElementException
        Description copied from interface: Optional
        Returns the optional value.
        Specified by:
        value in interface Optional<T>
        Throws:
        java.util.NoSuchElementException - if the optional value is not present.