de.caff.generics

## Interface TwoWayChoiceN<T>

- Type Parameters:
    `T` - value type
  Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

      @FunctionalInterface
      public interface TwoWayChoiceN<T>

  A choice between two values which may be `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)`.

  Since:
    December 27, 2022
  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    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.

- - ### Method Detail

    - #### choose

          @Nullable
          T choose(boolean select)

      Return the selected choice.
      Parameters:
        `select` - selector
      Returns:
        selected choice

    - #### andThen

          @NotNull
          default <R> TwoWayChoiceN<R> andThen(@NotNull
                                                        java.util.function.Function<? super T,? extends R> mapper)

      Convert this into a two-way choice with a different return value.
      Type Parameters:
        `R` - return type of returned adapted choice
      Parameters:
        `mapper` - mapper which maps the return value of this choice into the required one
      Returns:
        boolean choice with adapted return values

    - #### of

          @NotNull
          static <V> TwoWayChoiceN<V> of(@Nullable
                                                  V trueValue,
                                                  @Nullable
                                                  V falseValue)

      Create a two-way choice.
      Type Parameters:
        `V` - value type of selection
      Parameters:
        `trueValue` - value returned for `true` selector
        `falseValue` - value returned for `false` selector
      Returns:
        boolean choice which performs the same as `select ? trueValue : falseValue`