Class Either<X,Y>
java.lang.Object
com.supermartijn642.fusion.api.util.Either<X,Y>
Created 09/09/2022 by SuperMartijn642
-
Method Summary
Modifier and TypeMethodDescriptionabstract <S> SApplies the respective mapper to obtain an object of typeEither.abstract voidApplies the given consumer if this either is a left value.abstract voidApplies the given consumer if this either is a right value.abstract booleanisLeft()Whether the either is a left value or not.abstract booleanisRight()Whether the either is a right value or not.abstract Xleft()Will take this either as a left value.static <X,Y> Either<X, Y> left(X object) Creates a left either instance with the given value.abstract XleftOrElse(X other) Will take this either as a left value.abstract XleftOrElseGet(Supplier<X> other) Will take this either as a left value.Will take this either as a left value.<R,S> Either<R, S> Applies the respective mapper given whether this either is a left or right value.Applies the given mapper if this either is a left value.Applies the given mapper if this either is a right value.abstract Yright()Will take this either as a right value.static <X,Y> Either<X, Y> right(Y object) Creates a right either instance with the given value.abstract YrightOrElse(Y other) Will take this either as a right value.abstract YrightOrElseGet(Supplier<Y> other) Will take this either as a right value.Will take this either as a right value.
-
Method Details
-
left
Creates a left either instance with the given value. -
right
Creates a right either instance with the given value. -
isLeft
public abstract boolean isLeft()Whether the either is a left value or not. -
isRight
public abstract boolean isRight()Whether the either is a right value or not. -
left
Will take this either as a left value.- Throws:
NoSuchElementException- if the either is a right value
-
right
Will take this either as a right value.- Throws:
NoSuchElementException- if the either is a left value
-
leftOrElse
Will take this either as a left value. If this either is a right value, the given alternative will be returned. -
rightOrElse
Will take this either as a right value. If this either is a left value, the given alternative will be returned. -
leftOrElseGet
Will take this either as a left value. If this either is a right value, the given alternative will be resolved and returned. -
rightOrElseGet
Will take this either as a right value. If this either is a left value, the given alternative will be resolved and returned. -
leftOrNull
Will take this either as a left value. If this either is a right value,nullwill be returned. -
rightOrNull
Will take this either as a right value. If this either is a left value,nullwill be returned. -
mapLeft
Applies the given mapper if this either is a left value. -
mapRight
Applies the given mapper if this either is a right value. -
map
Applies the respective mapper given whether this either is a left or right value. -
flatMap
Applies the respective mapper to obtain an object of typeEither. -
ifLeft
Applies the given consumer if this either is a left value. -
ifRight
Applies the given consumer if this either is a right value.
-