public abstract class OneOf2OrNone<A,B> extends Object
Modifier | Constructor and Description |
---|---|
protected |
OneOf2OrNone(Object o,
Class<A> aClass,
Class<B> bClass,
int index)
Protected constructor for subclassing.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
int |
hashCode() |
<R> R |
match(Fn1<A,R> fa,
Fn1<B,R> fb,
Fn0<R> fz)
Languages that have union types built in have a match statement that works like this method.
|
String |
toString() |
protected OneOf2OrNone(Object o, Class<A> aClass, Class<B> bClass, int index)
o
- the item (may be null)aClass
- class 0 (to have at runtime for descriptive error messages and toString()).bClass
- class 1 (to have at runtime for descriptive error messages and toString()).index
- 0 means this represents an A, 1 represents a B, 2 represents a Nonepublic <R> R match(Fn1<A,R> fa, Fn1<B,R> fb, Fn0<R> fz)
fa
- the function to be executed if this OneOf stores the first type.fb
- the function to be executed if this OneOf stores the second type.fz
- the function to be executed if this OneOf stores a None.Copyright © 2017. All rights reserved.