java.lang.Object
net.luis.utils.util.Either<L,R>
net.luis.utils.util.Either.Right<L,R>
- Type Parameters:
L
- The type of the left valueR
- The type of the right value
Right implementation of the either.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.luis.utils.util.Either
Either.Left<L,
R>, Either.Right<L, R> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
void
Performs the given action if this either instance is a left instance.void
Performs the given action if this either instance is a right instance.boolean
isLeft()
Checks if this either instance is a left instance.boolean
isRight()
Checks if this either instance is a right instance.left()
Returns the left value as anOptional
.Returns the left value or throws an exception if it is a right either.<C,
D> @NotNull Either <C, D> mapBoth
(@NotNull Function<? super L, ? extends C> leftMapper, @NotNull Function<? super R, ? extends D> rightMapper) Maps the left and right values of this either instance to new values.<T> T
mapTo
(@NotNull Function<? super L, ? extends T> leftMapper, @NotNull Function<? super R, ? extends T> rightMapper) Maps the left and right values of this either instance to a new value.right()
Returns the right value as anOptional
.@UnknownNullability R
Returns the right value or throws an exception if it is a left either.toString()
-
Field Details
-
value
The value of the right either.
-
-
Constructor Details
-
Right
Constructs a new right either instance with the given value.- Parameters:
value
- The value of the right either
-
-
Method Details
-
isLeft
public boolean isLeft()Description copied from class:Either
Checks if this either instance is a left instance. -
isRight
public boolean isRight()Description copied from class:Either
Checks if this either instance is a right instance. -
ifLeft
Description copied from class:Either
Performs the given action if this either instance is a left instance. -
ifRight
Description copied from class:Either
Performs the given action if this either instance is a right instance. -
left
Description copied from class:Either
Returns the left value as anOptional
. -
right
Description copied from class:Either
Returns the right value as anOptional
. -
leftOrThrow
Description copied from class:Either
Returns the left value or throws an exception if it is a right either.- Specified by:
leftOrThrow
in classEither<L,
R> - Returns:
- The left value
-
rightOrThrow
Description copied from class:Either
Returns the right value or throws an exception if it is a left either.- Specified by:
rightOrThrow
in classEither<L,
R> - Returns:
- The right value
-
mapBoth
@NotNull public <C,D> @NotNull Either<C,D> mapBoth(@NotNull @NotNull Function<? super L, ? extends C> leftMapper, @NotNull @NotNull Function<? super R, ? extends D> rightMapper) Description copied from class:Either
Maps the left and right values of this either instance to new values. -
mapTo
public <T> T mapTo(@NotNull @NotNull Function<? super L, ? extends T> leftMapper, @NotNull @NotNull Function<? super R, ? extends T> rightMapper) Description copied from class:Either
Maps the left and right values of this either instance to a new value. -
toString
-
equals
-
hashCode
public int hashCode()
-