Class Optional<T>

java.lang.Object
org.apache.wayang.core.util.Optional<T>

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

    • Optional

      public Optional()
  • Method Details

    • 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:
      IllegalStateException - if isAvailable() is false
    • stream

      public abstract 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