Class Option.Some<A>

java.lang.Object
io.atlassian.fugue.Option<A>
io.atlassian.fugue.Option.Some<A>
All Implemented Interfaces:
Effect.Applicant<A>, Maybe<A>, Serializable, Iterable<A>
Enclosing class:
Option<A>

static final class Option.Some<A> extends Option<A>
One of the big two actual implementation classes.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • value

      private final A value
  • Constructor Details

    • Some

      private Some(A value)
  • Method Details

    • fold

      public <B> B fold(Supplier<? extends B> none, Function<? super A,? extends B> f)
      Description copied from class: Option
      If this is a some value apply the some function, otherwise get the None value.
      Specified by:
      fold in class Option<A>
      Type Parameters:
      B - the result type
      Parameters:
      none - the supplier of the None type
      f - the function to apply if this is a Some
      Returns:
      the appropriate value
    • get

      public A get()
      Description copied from interface: Maybe
      Get the value if defined. Throw an exception otherwise.
      Returns:
      the wrapped value
    • isDefined

      public boolean isDefined()
      Description copied from interface: Maybe
      If the type contains a value return true.
      Returns:
      true if this holds a value, false otherwise.
    • getOrError

      public A getOrError(Supplier<String> err)
      Description copied from interface: Maybe
      Get the value or throws an error with the supplied message if not defined.

      Used when absolutely sure this is defined.

      Parameters:
      err - the message for the error.
      Returns:
      the contained value.
    • getOrThrow

      public <X extends Throwable> A getOrThrow(Supplier<X> ifUndefined) throws X
      Description copied from interface: Maybe
      Get the value or throws the supplied throwable if not defined.

      Used when absolutely sure this is defined.

      Type Parameters:
      X - exception type
      Parameters:
      ifUndefined - the supplier of the throwable.
      Returns:
      the contained value.
      Throws:
      X - the throwable the supplier creates if there is no value.
    • foreach

      @Deprecated public void foreach(Effect<? super A> effect)
      Deprecated.
      Description copied from interface: Effect.Applicant
      Perform the given side-effect for each contained element.
      Parameters:
      effect - the input to use for performing the effect.
    • forEach

      public void forEach(Consumer<? super A> effect)
    • toOptional

      public Optional<A> toOptional()
      Description copied from class: Option
      Create an Optional from this option. Will throw a NullPointerException if this option is defined and contains a null value.
      Specified by:
      toOptional in class Option<A>
      Returns:
      Optional.of(Object) with the value if defined and not null, Optional.empty() if not defined.
    • toStream

      public Stream<A> toStream()
      Description copied from class: Option
      Create a Stream from this option.
      Specified by:
      toStream in class Option<A>
      Returns:
      Stream.of(Object) with the value if defined, Stream.empty() if not defined.
    • contains

      public boolean contains(A elem)
      Description copied from interface: Maybe
      Tests whether the option contains a given value as an element.
      Parameters:
      elem - the element to test
      Returns:
      true if the option has an element that is equal to elem, false otherwise