T - value type@FunctionalInterface
public interface TwoWayChoice<T>
true, the other with false.
This is basically the functional equivalent of the ternary operator
with the restriction that both values have to be null.
See TwoWayChoiceN with does not have this restriction.
The recommended way to create a two-way choice is of(Object, Object).
| Modifier and Type | Method and Description |
|---|---|
T |
choose(boolean select)
Return the selected choice.
|
static <V> TwoWayChoice<V> |
of(V trueValue,
V falseValue)
Create a two-way choice.
|
@NotNull T choose(boolean select)
select - selector@NotNull static <V> TwoWayChoice<V> of(@NotNull V trueValue, @NotNull V falseValue)
V - value type of selectiontrueValue - value returned for true selector, required to be not nullfalseValue - value returned for false selector, required to be not nullselect ? trueValue : falseValue