public abstract class

Option

extends Object
implements Iterable<T>
java.lang.Object
   ↳ com.atlassian.upm.api.util.Option<A>

Class Overview

An Option<T> is a wrapper for a value of type T. It can be either a none() or a some(Object)}

Summary

Public Methods
final boolean equals(Object obj)
final boolean exists(Predicate<A> f)
final Option<A> filter(Predicate<A> f)
final <B> Option<B> flatMap(Function<A, Option<B>> f)
Apply f to the wrapped value.
abstract <B> B fold(Supplier<B> none, Function<A, B> some)
If this is a some value apply the some function, otherwise get the none value.
final A get()
final <B extends A> A getOrElse(B other)
Returns wrapped value if this is a some, otherwise returns other.
final A getOrElse(Supplier<A> supplier)
final int hashCode()
final boolean isDefined()
@Nonnull final Iterator<A> iterator()
final <B> Option<B> map(Function<A, B> f)
Apply f to the wrapped value.
static <A> Option<A> none(Class<A> type)
static <A> Option<A> none()
static <A> Supplier<Option<A>> noneSupplier()
static <A> Option<A> option(A a)
static <A> Function<A, Option<A>> option()
final Option<A> orElse(Option<A> orElse)
Returns this if this is a some, otherwise returns orElse.
final Option<A> orElse(Supplier<Option<A>> orElse)
Returns this if this is a some, otherwise returns orElse.
static <A> Option<A> some(A value)
final String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Iterable

Public Methods

public final boolean equals (Object obj)

public final boolean exists (Predicate<A> f)

Parameters
f the predicate to apply if we are a some
Returns
  • true if this is a some value for which the predicate returns true, otherwise false

public final Option<A> filter (Predicate<A> f)

public final Option<B> flatMap (Function<A, Option<B>> f)

Apply f to the wrapped value.

Parameters
f function to apply to wrapped value
Returns
  • value returned from f

public abstract B fold (Supplier<B> none, Function<A, B> some)

If this is a some value apply the some function, otherwise get the none value.

Parameters
none the supplier of the None type
some the function to apply if we are a some
Returns
  • the appropriate value

public final A get ()

Returns
  • the wrapped value
Throws
NoSuchElementException if this is a none

public final A getOrElse (B other)

Returns wrapped value if this is a some, otherwise returns other.

Parameters
other value to return if this is a none
Returns
  • wrapped value if this is a some, otherwise returns other

public final A getOrElse (Supplier<A> supplier)

Returns
  • the wrapped value if this is a some, otherwise return the value supplied from the Supplier

public final int hashCode ()

public final boolean isDefined ()

Returns
  • true if this is a some, false otherwise.

@Nonnull public final Iterator<A> iterator ()

public final Option<B> map (Function<A, B> f)

Apply f to the wrapped value.

Parameters
f function to apply to wrapped value
Returns
  • new wrapped value

public static Option<A> none (Class<A> type)

public static Option<A> none ()

public static Supplier<Option<A>> noneSupplier ()

public static Option<A> option (A a)

public static Function<A, Option<A>> option ()

public final Option<A> orElse (Option<A> orElse)

Returns this if this is a some, otherwise returns orElse.

public final Option<A> orElse (Supplier<Option<A>> orElse)

Returns this if this is a some, otherwise returns orElse.

public static Option<A> some (A value)

public final String toString ()

Give us feedback

Was this documentation helpful?