Package io.atlassian.fugue
Class Either.LeftProjection
- java.lang.Object
-
- io.atlassian.fugue.Either.AbstractProjection<L,R>
-
- io.atlassian.fugue.Either.LeftProjection
-
- All Implemented Interfaces:
Effect.Applicant<L>,Either.Projection<L,R,L,R>,Maybe<L>,java.lang.Iterable<L>
public final class Either.LeftProjection extends Either.AbstractProjection<L,R> implements Either.Projection<L,R,L,R>
A left projection of an either value.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateLeftProjection()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <X> Either<X,R>ap(Either<java.util.function.Function<L,X>,R> either)Function application on this projection's value.<X> Either<X,R>apply(Either<java.util.function.Function<L,X>,R> either)Deprecated.since 3.0(package private) <X> Either<L,X>as()Coerces our right type as X.<X> Option<Either<L,X>>filter(java.util.function.Predicate<? super L> f)ReturnsNoneif this projection has no value or if the given predicatepdoes not hold for the value, otherwise, returns a left inSome.Either<L,R>filterOrElse(java.util.function.Predicate<? super L> p, java.util.function.Supplier<? extends R> orElseSupplier)Return aLeftif this is aLeftand the contained values satisfies the given predicate.<X,RR extends R>
Either<X,R>flatMap(java.util.function.Function<? super L,Either<X,RR>> f)Binds the given function across this projection's value if it has one.Lget()Get the value if defined.booleanisDefined()If the type contains a value return true.<X> Either<X,R>map(java.util.function.Function<? super L,X> f)Map the given function across this projection's value if it has one.Lon(java.util.function.Function<? super R,? extends L> f)The value of this projection or the result of the given function on the opposing projection's value.<X> Either<X,R>sequence(Either<X,R> e)Anonymous bind through this projection.(package private) <X> Either.Right<X,R>toRight()-
Methods inherited from class io.atlassian.fugue.Either.AbstractProjection
contains, either, exists, forall, foreach, forEach, getOr, getOrElse, getOrElse, getOrError, getOrNull, getOrThrow, isEmpty, iterator, toOption, toOptional, toStream
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.atlassian.fugue.Effect.Applicant
foreach
-
Methods inherited from interface io.atlassian.fugue.Either.Projection
either, toOption, toOptional, toStream
-
-
-
-
Method Detail
-
get
public L get()
Description copied from interface:MaybeGet the value if defined. Throw an exception otherwise.
-
isDefined
public boolean isDefined()
Description copied from interface:MaybeIf the type contains a value return true.
-
on
public L on(java.util.function.Function<? super R,? extends L> f)
Description copied from interface:Either.ProjectionThe value of this projection or the result of the given function on the opposing projection's value.
-
map
public <X> Either<X,R> map(java.util.function.Function<? super L,X> f)
Map the given function across this projection's value if it has one.- Type Parameters:
X- the LHS type- Parameters:
f- The function to map across this projection, must not return null- Returns:
- A new either value after mapping.
-
flatMap
public <X,RR extends R> Either<X,R> flatMap(java.util.function.Function<? super L,Either<X,RR>> f)
Binds the given function across this projection's value if it has one.- Type Parameters:
X- the LHS typeRR- The existing RHS or a subtype- Parameters:
f- The function to bind across this projection.- Returns:
- A new either value after binding.
-
toRight
<X> Either.Right<X,R> toRight()
-
sequence
public <X> Either<X,R> sequence(Either<X,R> e)
Anonymous bind through this projection.- Type Parameters:
X- the LHS type- Parameters:
e- The value to bind with.- Returns:
- An either after binding through this projection.
-
filter
public <X> Option<Either<L,X>> filter(java.util.function.Predicate<? super L> f)
ReturnsNoneif this projection has no value or if the given predicatepdoes not hold for the value, otherwise, returns a left inSome.- Type Parameters:
X- the RHS type- Parameters:
f- The predicate function to test on this projection's value.- Returns:
Noneif this projection has no value or if the given predicatepdoes not hold for the value, otherwise, returns a left inSome.
-
filterOrElse
public Either<L,R> filterOrElse(java.util.function.Predicate<? super L> p, java.util.function.Supplier<? extends R> orElseSupplier)
Return aLeftif this is aLeftand the contained values satisfies the given predicate. If this is aLeftbut the predicate is not satisfied, return aRightwith the value provided by the orElseSupplier. Return aRightif this aRightwith the contained value.- Parameters:
p- The predicate function to test on the right contained value.orElseSupplier- The supplier to execute when is a left, and predicate is unsatisfied- Returns:
- a new Either that will be either the existing left/right or a right with result of orElseSupplier
- Since:
- 4.7.0
-
ap
public <X> Either<X,R> ap(Either<java.util.function.Function<L,X>,R> either)
Function application on this projection's value.- Type Parameters:
X- the LHS type- Parameters:
either- The either of the function to apply on this projection's value.- Returns:
- The result of function application within either.
- Since:
- 3.0
-
apply
@Deprecated public <X> Either<X,R> apply(Either<java.util.function.Function<L,X>,R> either)
Deprecated.since 3.0Function application on this projection's value.- Type Parameters:
X- the LHS type- Parameters:
either- The either of the function to apply on this projection's value.- Returns:
- The result of function application within either.
- See Also:
ap
-
-