Package com.fa993.types.supertype
Class Either.OfThree<A,B,C>
- java.lang.Object
-
- com.fa993.types.supertype.Either.OfThree<A,B,C>
-
- Type Parameters:
A
- the type of the first possible valueB
- the type of the second possible valueC
- the type of the third possible value
- Direct Known Subclasses:
NumOrTwoSeqOrNdArr
- Enclosing class:
- Either
public static class Either.OfThree<A,B,C> extends Object
Represents an exclusive choice between three possible types.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OfThree(A first, B second, C third, Either.Selector selector)
Constructs anOfThree
object with the specified values and selector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <A,B,C>
Either.OfThree<A,B,C>first(A first)
Creates anOfThree
instance with the first value selected.A
getFirst()
Gets the first value if selected.B
getSecond()
Gets the second value if selected.Either.Selector
getSelector()
Gets the current selector.C
getThird()
Gets the third value if selected.static <A,B,C>
Either.OfThree<A,B,C>second(B second)
Creates anOfThree
instance with the second value selected.static <A,B,C>
Either.OfThree<A,B,C>third(C third)
Creates anOfThree
instance with the third value selected.
-
-
-
Constructor Detail
-
OfThree
protected OfThree(A first, B second, C third, Either.Selector selector)
Constructs anOfThree
object with the specified values and selector.- Parameters:
first
- the value of the first optionsecond
- the value of the second optionthird
- the value of the third optionselector
- the selector indicating the current choice
-
-
Method Detail
-
first
public static <A,B,C> Either.OfThree<A,B,C> first(A first)
Creates anOfThree
instance with the first value selected.- Type Parameters:
A
- the type of the first valueB
- the type of the second valueC
- the type of the third value- Parameters:
first
- the value of the first option- Returns:
- an
OfThree
instance with the first value selected
-
second
public static <A,B,C> Either.OfThree<A,B,C> second(B second)
Creates anOfThree
instance with the second value selected.- Type Parameters:
A
- the type of the first valueB
- the type of the second valueC
- the type of the third value- Parameters:
second
- the value of the second option- Returns:
- an
OfThree
instance with the second value selected
-
third
public static <A,B,C> Either.OfThree<A,B,C> third(C third)
Creates anOfThree
instance with the third value selected.- Type Parameters:
A
- the type of the first valueB
- the type of the second valueC
- the type of the third value- Parameters:
third
- the value of the third option- Returns:
- an
OfThree
instance with the third 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
-
getThird
public C getThird()
Gets the third value if selected.- Returns:
- the third value
- Throws:
IllegalStateException
- if the current selection is notThird
-
getSelector
public Either.Selector getSelector()
Gets the current selector.- Returns:
- the
Selector
indicating the current selection
-
-