Package de.marcely.bedwars.tools
Interface Either<L,R>
- Type Parameters:
L
- Left typeR
- Right type
- All Known Implementing Classes:
Either.Left
,Either.Right
public interface Either<L,R>
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Method Summary
Modifier and TypeMethodDescriptionboolean
hasLeft()
Returns if something has been set to the left field.boolean
hasRight()
Returns if something has been set to the right field.left()
Retrieve the left value.static <L,
R> Either <L, R> left
(L left) Creates a new Either with something set to the left value.right()
Retrieve the right value.static <L,
R> Either <L, R> right
(R right) Creates a new Either with something set to the right value.
-
Method Details
-
hasLeft
boolean hasLeft()Returns if something has been set to the left field.hasRight()
will returnfalse
if this method returnstrue
- Returns:
- true if this is a left value, false if this is a right value
-
hasRight
boolean hasRight()Returns if something has been set to the right field.hasLeft()
will returnfalse
if this method returnstrue
- Returns:
- true if this is a right value, false if this is a left value
-
left
Retrieve the left value.May return
null
even whenhasLeft()
returns true. Also returnsnull
if this is a right value.- Returns:
- The set left value
-
right
Retrieve the right value.May return
null
even whenhasRight()
returns true. Also returnsnull
if this is a left value.- Returns:
- The set right value
-
left
Creates a new Either with something set to the left value.- Type Parameters:
L
- The type for leftR
- The type for right- Parameters:
left
- The value that shall be set- Returns:
- The created Either instance
-
right
Creates a new Either with something set to the right value.- Type Parameters:
L
- The type for leftR
- The type for right- Parameters:
right
- The value that shall be set- Returns:
- The created Either instance
-