T
- value type@FunctionalInterface
public interface TwoWayChoiceN<T>
null
.
One value is associated with true
, the other with false
.
This is basically the functional equivalent of the ternary operator.
The recommended way to create a two-way choice is of(Object, Object)
.
Modifier and Type | Method and Description |
---|---|
default <R> TwoWayChoiceN<R> |
andThen(java.util.function.Function<? super T,? extends R> mapper)
Convert this into a two-way choice with a different return value.
|
T |
choose(boolean select)
Return the selected choice.
|
static <V> TwoWayChoiceN<V> |
of(V trueValue,
V falseValue)
Create a two-way choice.
|
@Nullable T choose(boolean select)
select
- selector@NotNull default <R> TwoWayChoiceN<R> andThen(@NotNull java.util.function.Function<? super T,? extends R> mapper)
R
- return type of returned adapted choicemapper
- mapper which maps the return value of this choice into the required one@NotNull static <V> TwoWayChoiceN<V> of(@Nullable V trueValue, @Nullable V falseValue)
V
- value type of selectiontrueValue
- value returned for true
selectorfalseValue
- value returned for false
selectorselect ? trueValue : falseValue