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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionbooleanhasLeft()Returns if something has been set to the left field.booleanhasRight()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 returnfalseif 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 returnfalseif 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
nulleven whenhasLeft()returns true. Also returnsnullif this is a right value.- Returns:
- The set left value
-
right
Retrieve the right value.May return
nulleven whenhasRight()returns true. Also returnsnullif 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
-