Package io.atlassian.fugue
Class Either.AbstractProjection<A,B>
java.lang.Object
io.atlassian.fugue.Either.AbstractProjection<A,B>
- All Implemented Interfaces:
Effect.Applicant<A>,Either.Projection<A,,B, L, R> Maybe<A>,Iterable<A>
- Direct Known Subclasses:
Either.LeftProjection,Either.RightProjection
Holds the common implementation for both projections.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether the option contains a given value as an element.either()The either value underlying this projection.final booleanWhether this isis definedand applying the predicate to the contained value returns true.final booleanReturnstrueif emptyor the result of the application of the given function to the value.final voidDeprecated.final voidfinal AGet the valueif definedor call the supplier and return its value if not.final ADeprecated.getOrElse(X x) Get the value if defined, otherwise returnsother.final AgetOrError(Supplier<String> err) Get the value or throws an error with the supplied message if not defined.final AGet the value if defined or null if not.getOrThrow(Supplier<X> ifUndefined) Get the value or throws the supplied throwable if not defined.final booleanisEmpty()If the type does not contain a value return true.iterator()Return an iterator for this type.toOption()Returns this projection's value inSomeif it exists, otherwiseNone.Returns this projection's value inOptional.of(T)if it exists, otherwiseOptional.empty().toStream()Returns this projection's value inStream.of(T)if it exists, otherwiseStream.empty().Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.atlassian.fugue.Either.Projection
onMethods inherited from interface java.lang.Iterable
spliterator
-
Constructor Details
-
AbstractProjection
AbstractProjection()
-
-
Method Details
-
iterator
Description copied from interface:MaybeReturn an iterator for this type. In most cases this takes the form of an iterator returning zero or one values. -
either
Description copied from interface:Either.ProjectionThe either value underlying this projection. -
isEmpty
public final boolean isEmpty()Description copied from interface:MaybeIf the type does not contain a value return true. -
toOption
Description copied from interface:Either.ProjectionReturns this projection's value inSomeif it exists, otherwiseNone. -
toOptional
Description copied from interface:Either.ProjectionReturns this projection's value inOptional.of(T)if it exists, otherwiseOptional.empty().- Specified by:
toOptionalin interfaceEither.Projection<A,B, L, R> - Returns:
- This projection's value in
ofif it exists, otherwiseempty.
-
toStream
Description copied from interface:Either.ProjectionReturns this projection's value inStream.of(T)if it exists, otherwiseStream.empty(). -
exists
Description copied from interface:MaybeWhether this isis definedand applying the predicate to the contained value returns true. -
getOrNull
Description copied from interface:MaybeGet the value if defined or null if not.Although the use of null is discouraged, code written to use these must often interface with code that expects and returns nulls.
-
forall
Description copied from interface:MaybeReturnstrueif emptyor the result of the application of the given function to the value. -
contains
Description copied from interface:MaybeTests whether the option contains a given value as an element. -
getOrError
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.- Specified by:
getOrErrorin interfaceMaybe<A>- Parameters:
err- the message for the error.- Returns:
- the contained value.
-
getOrThrow
Description copied from interface:MaybeGet the value or throws the supplied throwable if not defined.Used when absolutely sure this
is defined.- Specified by:
getOrThrowin interfaceMaybe<A>- 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.
-
getOr
Description copied from interface:MaybeGet the valueif definedor call the supplier and return its value if not. ReplacesMaybe.getOrElse(Supplier). Get the valueif definedor call the supplier and return its value if not. -
getOrElse
Deprecated.Description copied from interface:MaybeGet the valueif definedor call the supplier and return its value if not. -
getOrElse
Description copied from interface:MaybeGet the value if defined, otherwise returnsother.- Specified by:
getOrElsein interfaceMaybe<A>- Type Parameters:
X- default value type- Parameters:
x- value to return if thisis empty- Returns:
- wrapped value if this
is defined, otherwise returnsother
-
foreach
Deprecated.Description copied from interface:Effect.ApplicantPerform the given side-effect for each contained element.- Specified by:
foreachin interfaceEffect.Applicant<A>- Parameters:
f- the input to use for performing the effect.
-
forEach
-