Class Either<A,B>
java.lang.Object
fj.data.Either<A,B>
- Direct Known Subclasses:
Either.Left, Either.Right
The
Either type represents a value of one of two possible types (a disjoint union).
The data constructors; Left and Right represent the two possible
values. The Either type is often used as an alternative to
scala.Option where Left represents failure (by convention) and
Right is akin to Some.- Version:
- %build.number%
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classstatic final classA left projection of an either value.private static final classstatic final classA right projection of an either value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <X,Y> Either <X, Y> Map the given functions across the appropriate side.abstract <X> XThe catamorphism for either.First class catamorphism for either.final booleanfinal inthashCode()static <A,B> Either <A, B> If the condition satisfies, return the given B in right, otherwise, return the given A in left.abstract booleanisLeft()Returnstrueif this either is a left,falseotherwise.abstract booleanisRight()Returnstrueif this either is a right,falseotherwise.static <A,B> Either <A, B> Joins an either through left.static <A,B> Either <A, B> Joins an either through right.final Either.LeftProjection<A, B> left()Projects this either as a left.static <A,B> Either <A, B> left(A a) Construct a left value of either.left_()A function that constructs a left value of either.Map the given function across this either's left projection.leftMap_()Return a function that maps a given function across this either's left projection.static <A,B> List <A> Returns all the left values in the given list.static <A> ATakes anEitherto its contained value within left or right.final Either.RightProjection<A, B> right()Projects this either as a right.static <A,B> Either <A, B> right(B b) Construct a right value of either.right_()A function that constructs a right value of either.Map the given function across this either's right.Return a function that maps a given function across this either's right projection.static <A,B> List <B> Returns all the right values in the given list.sequenceLeft(List<Either<A, X>> a) Sequences through the left side of the either monad with a list of values.sequenceRight(List<Either<X, B>> a) Sequences through the right side of the either monad with a list of values.swap()If this is a left, then return the left value in right, or vice versa.final StringtoString()traverseIOLeft(F<A, IO<C>> f) Traversable instance of LeftProjection of Either for IO.traverseIORight(F<B, IO<C>> f) Traversable instance of RightProjection of Either for IO.traverseListLeft(F<A, List<C>> f) Traversable instance of LeftProjection of Either for List.traverseListRight(F<B, List<C>> f) Traversable instance of RightProjection of Either for List.traverseOptionLeft(F<A, Option<C>> f) Traversable instance of LeftProjection of Either for Option.traverseOptionRight(F<B, Option<C>> f) Traversable instance of RightProjection of Either for Option.traverseStreamLeft(F<A, Stream<C>> f) Traversable instance of LeftProjection of Either for Stream.traverseStreamRight(F<B, Stream<C>> f) Traversable instance of RightProjection of Either for Stream.
-
Constructor Details
-
Either
private Either()
-
-
Method Details
-
left
Projects this either as a left.- Returns:
- A left projection of this either.
-
right
Projects this either as a right.- Returns:
- A right projection of this either.
-
isLeft
public abstract boolean isLeft()Returnstrueif this either is a left,falseotherwise.- Returns:
trueif this either is a left,falseotherwise.
-
isRight
public abstract boolean isRight()Returnstrueif this either is a right,falseotherwise.- Returns:
trueif this either is a right,falseotherwise.
-
either
-
bimap
-
equals
-
hashCode
-
swap
-
left
Construct a left value of either.- Parameters:
a- The value underlying the either.- Returns:
- A left value of either.
-
left_
-
right_
-
right
Construct a right value of either.- Parameters:
b- The value underlying the either.- Returns:
- A right value of either.
-
either_
-
leftMap
-
leftMap_
Return a function that maps a given function across this either's left projection.- Type Parameters:
A- the type of the right valueB- the type of the left valueX- the type of the function output- Returns:
- A function that maps another function across an either's left projection.
-
rightMap
-
rightMap_
Return a function that maps a given function across this either's right projection.- Type Parameters:
A- the type of the right valueB- the type of the left valueX- the type of the function output- Returns:
- A function that maps another function across an either's right projection.
-
joinLeft
-
joinRight
-
sequenceLeft
-
sequenceRight
-
traverseListRight
-
traverseListLeft
-
traverseIORight
-
traverseIOLeft
-
traverseOptionRight
-
traverseOptionLeft
-
traverseStreamRight
-
traverseStreamLeft
-
reduce
Takes anEitherto its contained value within left or right.- Parameters:
e- The either to reduce.- Returns:
- An
Eitherto its contained value within left or right.
-
iif
If the condition satisfies, return the given B in right, otherwise, return the given A in left.- Parameters:
c- The condition to test.right- The right value to use if the condition satisfies.left- The left value to use if the condition does not satisfy.- Returns:
- A constructed either based on the given condition.
-
lefts
-
rights
-
toString
-