public interface Or<G,B>
OneOf2
union type.
This makes it a little less general, and more meaningful to use.Modifier and Type | Interface and Description |
---|---|
static class |
Or.Bad<G,B>
Represents the presence of a Bad value (and absence of a Good).
|
static class |
Or.Good<G,B>
Represents the presence of a Good value (and absence of a Bad).
|
Modifier and Type | Method and Description |
---|---|
B |
bad()
Returns the bad value if this is a Bad, or throws an exception if this is a Good.
|
static <G,B> Or<G,B> |
bad(B bad)
Construct a new Bad from the given object.
|
G |
good()
Returns the good value if this is a Good, or throws an exception if this is a Bad.
|
static <G,B> Or<G,B> |
good(G good)
Construct a new Good from the given object.
|
boolean |
isBad()
Returns true if this Or has a bad value.
|
boolean |
isGood()
Returns true if this Or has a good value.
|
<R> R |
match(Fn1<G,R> fg,
Fn1<B,R> fb)
Exactly one of these functions will be executed - determined by whether this is a Good or a Bad.
|
static <G,B> Or<G,B> good(G good)
static <G,B> Or<G,B> bad(B bad)
boolean isGood()
boolean isBad()
G good()
B bad()
<R> R match(Fn1<G,R> fg, Fn1<B,R> fb)
fg
- 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.Copyright © 2017. All rights reserved.