Either.Left<L,R>, Either.Right<L,R>| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o)
Evaluates if object to compare is of the same DataObject type and all non-transient
fields are equal as well
|
<T> T |
fold(java.util.function.Function<L,T> foldLeft,
java.util.function.Function<R,T> foldRight)
Transforms a value and returns it
|
L |
getLeft()
|
<T extends java.lang.Throwable> |
getLeftOrThrow(java.util.function.Supplier<? extends T> exceptionSupplier)
|
R |
getRight()
|
<T extends java.lang.Throwable> |
getRightOrThrow(java.util.function.Supplier<? extends T> exceptionSupplier)
|
<TL extends java.lang.Throwable,TR extends java.lang.Throwable> |
handle(ValueHandler<? super L,? extends TL> leftValueHandler,
ValueHandler<? super R,? extends TR> rightValueHandler)
|
<T extends java.lang.Throwable> |
handleLeft(ValueHandler<? super L,? extends T> leftValueHandler)
|
<T extends java.lang.Throwable> |
handleRight(ValueHandler<? super R,? extends T> rightValueHandler)
|
int |
hashCode()
Returns hashCode calculated using reflection
|
<T extends java.lang.Throwable> |
ifLeftThrow(java.util.function.Function<L,? extends T> exceptionSupplier)
|
<T extends java.lang.Throwable> |
ifRightThrow(java.util.function.Function<R,? extends T> exceptionSupplier)
|
boolean |
isLeft()
|
boolean |
isRight()
|
<L2,R2> Either<L2,R2> |
map(java.util.function.Function<L,L2> leftValueMapper,
java.util.function.Function<R,R2> rightValueMapper)
|
<L2> Either<L2,R> |
mapLeft(java.util.function.Function<L,L2> leftValueMapper)
|
<R2> Either<L,R2> |
mapRight(java.util.function.Function<R,R2> rightValueMapper)
|
Either<R,L> |
swap()
Swaps left and right value of an
Either |
R |
value()
Returns right value
|
toStringpublic Either<R,L> swap()
EitherEitherpublic boolean isLeft()
Eitherpublic boolean isRight()
Eitherpublic L getLeft() throws java.util.NoSuchElementException
Eitherpublic <T extends java.lang.Throwable> L getLeftOrThrow(java.util.function.Supplier<? extends T> exceptionSupplier) throws T extends java.lang.Throwable
EitherEither is of type Left.
Throws Exception provided via exceptionSupplier if value is defined as Right Either.getLeftOrThrow in class Either<L,R>T - type of Exception that will be provided by exceptionSupplierexceptionSupplier - that should provide Exception in case of Right EitherEither is of type LeftT - Exception provided via exceptionSupplier if value is defined as Right Either.T extends java.lang.Throwablepublic <T extends java.lang.Throwable> R getRightOrThrow(java.util.function.Supplier<? extends T> exceptionSupplier)
Eitherpublic <L2,R2> Either<L2,R2> map(java.util.function.Function<L,L2> leftValueMapper, java.util.function.Function<R,R2> rightValueMapper)
Eitherpublic <L2> Either<L2,R> mapLeft(java.util.function.Function<L,L2> leftValueMapper)
Eitherpublic <R2> Either<L,R2> mapRight(java.util.function.Function<R,R2> rightValueMapper)
Eitherpublic <T> T fold(java.util.function.Function<L,T> foldLeft, java.util.function.Function<R,T> foldRight)
Eitherpublic <T extends java.lang.Throwable> Either<L,R> handleLeft(ValueHandler<? super L,? extends T> leftValueHandler)
Eitherpublic <T extends java.lang.Throwable> Either<L,R> handleRight(ValueHandler<? super R,? extends T> rightValueHandler) throws T extends java.lang.Throwable
EitherrightValueHandler if value is defined as Right Either.
The action is ignored if value is defined as Left Either.handleRight in class Either<L,R>T - class of potential Throwable thrown by rightValueHandlerrightValueHandler - action that is executed for Right EitherEither to allow method chainingT - in case the rightValueHandler throws TT extends java.lang.Throwablepublic <TL extends java.lang.Throwable,TR extends java.lang.Throwable> Either<L,R> handle(ValueHandler<? super L,? extends TL> leftValueHandler, ValueHandler<? super R,? extends TR> rightValueHandler) throws TR extends java.lang.Throwable
EitherleftValueHandler if value is defined as Left Either.
Executes provided rightValueHandler if value is defined as Right Either.handle in class Either<L,R>TL - class of potential Throwable thrown by leftValueHandlerTR - class of potential Throwable thrown by rightValueHandlerleftValueHandler - action that is executed for Left EitherrightValueHandler - action that is executed for Right EitherEither to allow method chainingTR - in case the rightValueHandler throws TTR extends java.lang.Throwablepublic <T extends java.lang.Throwable> Either<L,R> ifLeftThrow(java.util.function.Function<L,? extends T> exceptionSupplier)
Eitherpublic <T extends java.lang.Throwable> Either<L,R> ifRightThrow(java.util.function.Function<R,? extends T> exceptionSupplier) throws T extends java.lang.Throwable
EitherException provided via exceptionSupplier if value is defined as Right Either.
The exceptionSupplier is ignored if value is defined as Left Either.ifRightThrow in class Either<L,R>T - type of Exception that will be provided by exceptionSupplierexceptionSupplier - that should provide Exception in case of Right EitherT - Exception provided via exceptionSupplier if value is defined as Right EitherT extends java.lang.Throwablepublic R value()
public boolean equals(java.lang.Object o)
DataObjectequals in class DataObjecto - value to compare totrue if other value is of the same DataObject type and all
non-transient field are equal. Otherwise returns falsepublic int hashCode()
DataObjecthashCode in class DataObject