Package io.atlassian.fugue
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>,java.io.Serializable,java.lang.Iterable<A>
static final class Option.Some<A> extends Option<A>
One of the big two actual implementation classes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.atlassian.fugue.Option
Option.None, Option.Some<A>
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDprivate Avalue
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancontains(A elem)Tests whether the option contains a given value as an element.<B> Bfold(java.util.function.Supplier<? extends B> none, java.util.function.Function<? super A,? extends B> f)If this is a some value apply the some function, otherwise get the None value.voidforeach(Effect<? super A> effect)Deprecated.voidforEach(java.util.function.Consumer<? super A> effect)Aget()Get the value if defined.AgetOrError(java.util.function.Supplier<java.lang.String> err)Get the value or throws an error with the supplied message if not defined.<X extends java.lang.Throwable>
AgetOrThrow(java.util.function.Supplier<X> ifUndefined)Get the value or throws the supplied throwable if not defined.booleanisDefined()If the type contains a value return true.java.util.Optional<A>toOptional()Create anOptionalfrom this option.java.util.stream.Stream<A>toStream()Create aStreamfrom this option.-
Methods inherited from class io.atlassian.fugue.Option
defined, equals, exists, filter, filterNot, flatMap, forall, fromOptional, getOr, getOrElse, getOrElse, getOrNull, hashCode, isEmpty, iterator, map, none, none, noneSupplier, option, orElse, orElse, some, toLeft, toRight, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
value
private final A value
-
-
Constructor Detail
-
Some
private Some(A value)
-
-
Method Detail
-
fold
public <B> B fold(java.util.function.Supplier<? extends B> none, java.util.function.Function<? super A,? extends B> f)Description copied from class:OptionIf this is a some value apply the some function, otherwise get the None value.
-
get
public A get()
Description copied from interface:MaybeGet the value if defined. Throw an exception otherwise.- Returns:
- the wrapped value
-
isDefined
public boolean isDefined()
Description copied from interface:MaybeIf the type contains a value return true.- Returns:
trueif this holds a value,falseotherwise.
-
getOrError
public A getOrError(java.util.function.Supplier<java.lang.String> err)
Description copied from interface:MaybeGet 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 java.lang.Throwable> A getOrThrow(java.util.function.Supplier<X> ifUndefined) throws X extends java.lang.Throwable
Description copied from interface:MaybeGet 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.X extends java.lang.Throwable
-
foreach
@Deprecated public void foreach(Effect<? super A> effect)
Deprecated.Description copied from interface:Effect.ApplicantPerform the given side-effect for each contained element.- Parameters:
effect- the input to use for performing the effect.
-
forEach
public void forEach(java.util.function.Consumer<? super A> effect)
-
toOptional
public java.util.Optional<A> toOptional()
Description copied from class:OptionCreate anOptionalfrom this option. Will throw aNullPointerExceptionif this option is defined and contains a null value.- Specified by:
toOptionalin classOption<A>- Returns:
Optional.of(Object)with the value if defined and not null,Optional.empty()if not defined.
-
toStream
public java.util.stream.Stream<A> toStream()
Description copied from class:OptionCreate aStreamfrom this option.
-
-