Package org.fulib.fx.data
Class Either<L,R>
java.lang.Object
org.fulib.fx.data.Either<L,R>
- Type Parameters:
L- The first type (left)R- The second type (right)
A class representing two possible values with different types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget()Returns the value of the present side.<T> TReturns the value of the present side cast to the given type.getLeft()Returns the left value if present, otherwise null.getRight()Returns the right value if present, otherwise null.booleanisLeft()Returns whether the left value is present.booleanisRight()Returns whether the right value is present.static <L,R> Either<L, R> left(L left) Creates a new Either with the left value set.static <L,R> Either<L, R> right(R right) Creates a new Either with the right value set.toString()
-
Constructor Details
-
Either
-
-
Method Details
-
left
Creates a new Either with the left value set.- Type Parameters:
L- the type of the left valueR- the type of the right value- Parameters:
left- the left value- Returns:
- the new Either
-
right
Creates a new Either with the right value set.- Type Parameters:
L- the type of the left valueR- the type of the right value- Parameters:
right- the right value- Returns:
- the new Either
-
isLeft
public boolean isLeft()Returns whether the left value is present.- Returns:
- whether the left value is present
-
isRight
public boolean isRight()Returns whether the right value is present.- Returns:
- whether the right value is present
-
getLeft
Returns the left value if present, otherwise null.- Returns:
- the left value if present, otherwise null
-
getRight
Returns the right value if present, otherwise null.- Returns:
- the right value if present, otherwise null
-
get
Returns the value of the present side.- Returns:
- the value of the present side
-
get
Returns the value of the present side cast to the given type.- Type Parameters:
T- the type of the value- Parameters:
type- the type of the value- Returns:
- the value of the present side
- Throws:
ClassCastException- if the value is not of the given type
-
toString
-