Class Optional<T>


  • public abstract class Optional<T>
    extends java.lang.Object
    Utility similar to Optional. However, it supports null as a valid value.
    • Constructor Detail

      • Optional

        public Optional()
    • Method Detail

      • isAvailable

        public abstract boolean isAvailable()
        Returns:
        whether this instance contains a value.
      • getValue

        public abstract T getValue()
        Returns:
        the value contained by this instance
        Throws:
        java.lang.IllegalStateException - if isAvailable() is false
      • stream

        public abstract java.util.stream.Stream<T> stream()
        Returns:
        a Stream containing the optional value
      • na

        public static <T> Optional<T> na()
        Create a n/a instance.
        Returns:
        an Optional without a value
      • of

        public static <T> Optional<T> of​(T value)
        Create a new instance with the given value.
        Parameters:
        value - the value of the new Optional
        Returns:
        the new instance