Package io.camunda.zeebe.util
Class Either.Right<L,R>
java.lang.Object
io.camunda.zeebe.util.Either.Right<L,R>
- Type Parameters:
L- The left typeR- The right type
- All Implemented Interfaces:
Either<L,R>
A right for either a left or right. By convention, right is used for success and left for
error.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.camunda.zeebe.util.Either
Either.EitherOptional<R>, Either.Left<L,R>, Either.Right<L, R> -
Method Summary
Modifier and TypeMethodDescriptionbooleanFlatmaps the right value into a new Either, if this is aEither.Right.get()Returns the right value, if this is aEither.Right.getLeft()Returns the left value, if this is aEither.Left.Returns the right value, or a default value if this is aEither.Left.inthashCode()voidPerforms the given action with the value if this is aEither.Left, otherwise does nothing.voidPerforms the given action with the value if this is aEither.Right, otherwise does nothing.voidifRightOrLeft(Consumer<R> rightAction, Consumer<L> leftAction) Performs the given right action with the value if this is aEither.Right, otherwise performs the given left action with the value.booleanisLeft()Returns true if this Either is aEither.Left.booleanisRight()Returns true if this Either is aEither.Right.Maps the right value, if this is aEither.Right.Maps the left value, if this is aEither.Left.toString()
-
Method Details
-
isRight
public boolean isRight()Description copied from interface:EitherReturns true if this Either is aEither.Right. -
isLeft
public boolean isLeft()Description copied from interface:EitherReturns true if this Either is aEither.Left. -
get
Description copied from interface:EitherReturns the right value, if this is aEither.Right. -
getOrElse
Description copied from interface:EitherReturns the right value, or a default value if this is aEither.Left.- Specified by:
getOrElsein interfaceEither<L,R> - Parameters:
defaultValue- the default value- Returns:
- the right value, or the default value if this is a
Either.Left
-
getLeft
Description copied from interface:EitherReturns the left value, if this is aEither.Left. -
map
Description copied from interface:EitherMaps the right value, if this is aEither.Right.- Specified by:
mapin interfaceEither<L,R> - Type Parameters:
T- the type of the resulting right value- Parameters:
right- the mapping function for the right value- Returns:
- a mapped
Either.Rightor the sameEither.Left
-
mapLeft
Description copied from interface:EitherMaps the left value, if this is aEither.Left.- Specified by:
mapLeftin interfaceEither<L,R> - Type Parameters:
T- the type of the resulting left value- Parameters:
left- the mapping function for the left value- Returns:
- a mapped
Either.Leftor the sameEither.Right
-
flatMap
Description copied from interface:EitherFlatmaps the right value into a new Either, if this is aEither.Right.A common use case is to map a right value to a new right, unless some error occurs in which case the value can be mapped to a new left. Note that this flatMap does not allow to alter the type of the left side. Example:
Either.<String, Integer>right(0) // => Right(0) .flatMap(x -> Either.right(x + 1)) // => Right(1) .flatMap(x -> Either.left("an error occurred")) // => Left("an error occurred") .getLeft(); // => "an error occurred"- Specified by:
flatMapin interfaceEither<L,R> - Type Parameters:
T- the type of the right side of the resulting either- Parameters:
right- the flatmapping function for the right value- Returns:
- either a mapped
Either.Rightor a newEither.Leftif this is a right; otherwise the same left, but cast to consider the new type of the right.
-
ifRight
Description copied from interface:EitherPerforms the given action with the value if this is aEither.Right, otherwise does nothing. -
ifLeft
Description copied from interface:EitherPerforms the given action with the value if this is aEither.Left, otherwise does nothing. -
ifRightOrLeft
Description copied from interface:EitherPerforms the given right action with the value if this is aEither.Right, otherwise performs the given left action with the value.- Specified by:
ifRightOrLeftin interfaceEither<L,R> - Parameters:
rightAction- the consuming function for the right valueleftAction- the consuming function for the left value
-
hashCode
public int hashCode() -
equals
-
toString
-