Package com.identityworksllc.iiq.common
Class Either<L,R>
- java.lang.Object
-
- com.identityworksllc.iiq.common.Either<L,R>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
L
getLeft()
Returns the left object or throws aNoSuchElementException
if this Either contains a right objectR
getRight()
Returns the right object or throws aNoSuchElementException
if this Either contains a left objectint
hashCode()
boolean
hasLeft()
boolean
hasRight()
static <A> Either<A,?>
left(A l)
Creates an Either object containing the given object on the left.static <B> Either<?,B>
right(B r)
Creates an Either object containing the given object on the right.String
toString()
-
-
-
Method Detail
-
left
public static <A> Either<A,?> left(A l)
Creates an Either object containing the given object on the left.The type of the right object is undefined.
- Type Parameters:
A
- The left object type- Parameters:
l
- The non-null left object- Returns:
- The Either object
-
right
public static <B> Either<?,B> right(B r)
Creates an Either object containing the given object on the right.The type of the left object is undefined.
- Type Parameters:
B
- The right object type- Parameters:
r
- The non-null right object- Returns:
- The Either object
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classObject
- See Also:
Object.equals(Object)
-
getLeft
public L getLeft()
Returns the left object or throws aNoSuchElementException
if this Either contains a right object- Returns:
- The left object
- Throws:
NoSuchElementException
- if this is a right Either
-
getRight
public R getRight()
Returns the right object or throws aNoSuchElementException
if this Either contains a left object- Returns:
- The right object
- Throws:
NoSuchElementException
- if this is a left Either
-
hasLeft
public boolean hasLeft()
- Returns:
- True if this Either has a left object
-
hasRight
public boolean hasRight()
- Returns:
- True if this Either has a right object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
-