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 booleanequals(Object o)LgetLeft()Returns the left object or throws aNoSuchElementExceptionif this Either contains a right objectRgetRight()Returns the right object or throws aNoSuchElementExceptionif this Either contains a left objectinthashCode()booleanhasLeft()booleanhasRight()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.StringtoString()
-
-
-
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:
equalsin classObject- See Also:
Object.equals(Object)
-
getLeft
public L getLeft()
Returns the left object or throws aNoSuchElementExceptionif 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 aNoSuchElementExceptionif 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:
hashCodein classObject- See Also:
Object.hashCode()
-
toString
public String toString()
- Overrides:
toStringin classObject- See Also:
Object.toString()
-
-