Package com.fa993.types.supertype
Class Either.OfTwo<A,B>
- java.lang.Object
-
- com.fa993.types.supertype.Either.OfTwo<A,B>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedOfTwo(A first, B second, Either.Selector selector)Constructs anOfTwoobject with the specified values and selector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <A,B>
Either.OfTwo<A,B>first(A first)Creates anOfTwoinstance with the first value selected.AgetFirst()Gets the first value if selected.BgetSecond()Gets the second value if selected.Either.SelectorgetSelector()Gets the current selector.static <A,B>
Either.OfTwo<A,B>second(B second)Creates anOfTwoinstance with the second value selected.
-
-
-
Constructor Detail
-
OfTwo
protected OfTwo(A first, B second, Either.Selector selector)
Constructs anOfTwoobject with the specified values and selector.- Parameters:
first- the value of the first optionsecond- the value of the second optionselector- the selector indicating the current choice
-
-
Method Detail
-
first
public static <A,B> Either.OfTwo<A,B> first(A first)
Creates anOfTwoinstance with the first value selected.- Type Parameters:
A- the type of the first valueB- the type of the second value- Parameters:
first- the value of the first option- Returns:
- an
OfTwoinstance with the first value selected
-
second
public static <A,B> Either.OfTwo<A,B> second(B second)
Creates anOfTwoinstance with the second value selected.- Type Parameters:
A- the type of the first valueB- the type of the second value- Parameters:
second- the value of the second option- Returns:
- an
OfTwoinstance with the second value selected
-
getFirst
public A getFirst()
Gets the first value if selected.- Returns:
- the first value
- Throws:
IllegalStateException- if the current selection is notFirst
-
getSecond
public B getSecond()
Gets the second value if selected.- Returns:
- the second value
- Throws:
IllegalStateException- if the current selection is notSecond
-
getSelector
public Either.Selector getSelector()
Gets the current selector.- Returns:
- the
Selectorindicating the current selection
-
-