de.caff.generics.function

## Interface Procedure2<P1,P2>

- Type Parameters:
    `P1` - first parameter type
    `P2` - second parameter type
  All Superinterfaces:
    java.util.function.BiConsumer<P1,P2>, java.util.function.Consumer<ITuple2<? extends P1,? extends P2>>, Procedure1<ITuple2<? extends P1,? extends P2>>
  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 Procedure2<P1,P2>
      extends java.util.function.BiConsumer<P1,P2>, Procedure1<ITuple2<? extends P1,? extends P2>>

  Function without return and with two parameters. This provides the same functional interface as modern Java's `BiConsumer`, but in a more extensible way. As it is extending `BiConsumer` it can be used anywhere
  Author:
    Rammi
  See Also:
    `Procedure0`, `Procedure1`, `Procedure3`, `Procedure4`, `Procedure5`, `Procedure6`, `Procedure7`, `Procedure8`, `Procedure9`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Procedure2<?,?>` | `NULL` Procedure with two arguments which does nothing.

  - ### Method Summary

    All Methods Static Methods Instance Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default void` | `accept(ITuple2<? extends P1,? extends P2> tuple2)` Expand a tuple into the arguments of this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP> Procedure1<FP>` | `after1(java.util.function.Function<FP,FR> before)` Get a chained procedure which first applies the given function, then this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2> Procedure2<FP1,FP2>` | `after2(java.util.function.BiFunction<FP1,FP2,FR> before)` Get a chained procedure which first applies the given 2-parameter function, then this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3> Procedure3<FP1,FP2,FP3>` | `after3(Function3<FR,FP1,FP2,FP3> before)` Get a chained procedure which first applies the given 3-parameter function, then this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5> Procedure5<FP1,FP2,FP3,FP4,FP5>` | `after5(Function5<FR,FP1,FP2,FP3,FP4,FP5> before)` Get a chained procedure which first applies the given 5-parameter function, then this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6> Procedure6<FP1,FP2,FP3,FP4,FP5,FP6>` | `after6(Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)` Get a chained procedure which first applies the given 6-parameter function, then this procedure.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> Procedure7<FP1,FP2,FP3,FP4,FP5,FP6,FP7>` | `after7(Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)` Get a chained procedure which first applies the given 7-parameter function, then this one.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> Procedure8<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8>` | `after8(Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)` Get a chained procedure which first applies the given 8-parameter function, then this one.
    `default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> Procedure9<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9>` | `after9(Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)` Get a chained procedure which first applies the given 9-parameter function, then this one.
    `default void` | `apply(P1 arg1, P2 arg2)` Run the function.
    `static <T1,T2> Procedure2<T1,T2>` | `empty()` Return a procedure which does nothing.
    `static <T1,T2> Procedure2<T1,T2>` | `from(java.util.function.BiConsumer<T1,T2> bico)` Make a `BiConsumer` usable as a `Procedure2`.
    `static <E extends java.lang.Exception,PP1,PP2> Procedure2<PP1,PP2>` | `nonFragile(FragileProcedure2<E,? super PP1,? super PP2> fragileProc)` Convert a 2-argument procedure which might throw a checked exception into one which does throw an unchecked exception.
    `static <E extends java.lang.Exception,PP1,PP2> Procedure2<PP1,PP2>` | `nonFragileX(FragileProcedure2<E,? super PP1,? super PP2> fragileProc, Procedure3<? super E,? super PP1,? super PP2> exceptionHandler)` Convert a 2-argument procedure which might throw a checked exception into one for which you can decide what happens with the exception.
    `default Procedure1<P2>` | `partial1(P1 argument)` Get a partially applied procedure.
    `default Procedure1<P1>` | `partial2(P2 argument)` Get a partially applied procedure.
    `default Procedure1<P2>` | `partialLeft(P1 argument)` Get a partially applied procedure.
    `default Procedure1<P1>` | `partialRight(P2 argument)` Get a partially applied procedure.

    - ### Methods inherited from interface java.util.function.BiConsumer

      `accept, andThen`

    - ### Methods inherited from interface de.caff.generics.function.Procedure1

      `apply, applyNonNull, from, nonFragile, nonFragileX, partial`

    - ### Methods inherited from interface java.util.function.Consumer

      `andThen`

- - ### Field Detail

    - #### NULL

          @NotNull
          static final Procedure2<?,?> NULL

      Procedure with two arguments which does nothing. Use `empty()` instead.

  - ### Method Detail

    - #### accept

          default void accept(@NotNull
                              ITuple2<? extends P1,? extends P2> tuple2)

      Expand a tuple into the arguments of this procedure.
      Specified by:
        `accept` in interface `java.util.function.Consumer<ITuple2<? extends P1,? extends P2>>`
      Parameters:
        `tuple2` - tuple to expand

    - #### apply

          default void apply(P1 arg1,
                             P2 arg2)

      Run the function.
      Parameters:
        `arg1` - first function argument
        `arg2` - second function argument

    - #### partialLeft

          @NotNull
          default Procedure1<P2> partialLeft(P1 argument)

      Get a partially applied procedure.
      Parameters:
        `argument` - value applied for first argument
      Returns:
        partially evaluated procedure

    - #### partial1

          @NotNull
          default Procedure1<P2> partial1(P1 argument)

      Get a partially applied procedure. This is the same as `partialLeft(Object)`, but with a name which is more consistent with functions having more arguments.
      Parameters:
        `argument` - value applied for first argument
      Returns:
        partially evaluated procedure

    - #### partialRight

          @NotNull
          default Procedure1<P1> partialRight(P2 argument)

      Get a partially applied procedure.
      Parameters:
        `argument` - value applied for second argument
      Returns:
        partially evaluated procedure

    - #### partial2

          @NotNull
          default Procedure1<P1> partial2(P2 argument)

      Get a partially applied procedure. This is the same as `partialRight(Object)`, but with a name which is more consistent with functions having more arguments.
      Parameters:
        `argument` - value applied for second argument
      Returns:
        partially evaluated procedure

    - #### after1

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP> Procedure1<FP> after1(@NotNull
                                                                                                    java.util.function.Function<FP,FR> before)

      Get a chained procedure which first applies the given function, then this procedure. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP` - function `before`'s parameter type, same for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of function and this procedure

    - #### after2

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2> Procedure2<FP1,FP2> after2(@NotNull
                                                                                                              java.util.function.BiFunction<FP1,FP2,FR> before)

      Get a chained procedure which first applies the given 2-parameter function, then this procedure. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, same for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after3

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3> Procedure3<FP1,FP2,FP3> after3(@NotNull
                                                                                                                      Function3<FR,FP1,FP2,FP3> before)

      Get a chained procedure which first applies the given 3-parameter function, then this procedure. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after5

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5> Procedure5<FP1,FP2,FP3,FP4,FP5> after5(@NotNull
                                                                                                                                      Function5<FR,FP1,FP2,FP3,FP4,FP5> before)

      Get a chained procedure which first applies the given 5-parameter function, then this procedure. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this function.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
        `FP4` - function `before`'s fourth parameter type, sane for returned procedure
        `FP5` - function `before`'s fifth parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after6

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6> Procedure6<FP1,FP2,FP3,FP4,FP5,FP6> after6(@NotNull
                                                                                                                                              Function6<FR,FP1,FP2,FP3,FP4,FP5,FP6> before)

      Get a chained procedure which first applies the given 6-parameter function, then this procedure. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this function.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
        `FP4` - function `before`'s fourth parameter type, sane for returned procedure
        `FP5` - function `before`'s fifth parameter type, sane for returned procedure
        `FP6` - function `before`'s sixth parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after7

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7> Procedure7<FP1,FP2,FP3,FP4,FP5,FP6,FP7> after7(@NotNull
                                                                                                                                                      Function7<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7> before)

      Get a chained procedure which first applies the given 7-parameter function, then this one. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
        `FP4` - function `before`'s fourth parameter type, sane for returned procedure
        `FP5` - function `before`'s fifth parameter type, sane for returned procedure
        `FP6` - function `before`'s sixth parameter type, sane for returned procedure
        `FP7` - function `before`'s seventh parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after8

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> Procedure8<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> after8(@NotNull
                                                                                                                                                              Function8<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8> before)

      Get a chained procedure which first applies the given 8-parameter function, then this one. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
        `FP4` - function `before`'s fourth parameter type, sane for returned procedure
        `FP5` - function `before`'s fifth parameter type, sane for returned procedure
        `FP6` - function `before`'s sixth parameter type, sane for returned procedure
        `FP7` - function `before`'s seventh parameter type, sane for returned procedure
        `FP8` - function `before`'s seventh parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### after9

          @NotNull
          default <FR extends ITuple2<? extends P1,? extends P2>,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> Procedure9<FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> after9(@NotNull
                                                                                                                                                                      Function9<FR,FP1,FP2,FP3,FP4,FP5,FP6,FP7,FP8,FP9> before)

      Get a chained procedure which first applies the given 9-parameter function, then this one. The given function has to return a `ITuple2` with matching parametric types which are applied in their order to this procedure.
      Type Parameters:
        `FR` - function `before`'s return type, has to be a 2-tuple with matching types
        `FP1` - function `before`'s first parameter type, sane for returned procedure
        `FP2` - function `before`'s second parameter type, sane for returned procedure
        `FP3` - function `before`'s third parameter type, sane for returned procedure
        `FP4` - function `before`'s fourth parameter type, sane for returned procedure
        `FP5` - function `before`'s fifth parameter type, sane for returned procedure
        `FP6` - function `before`'s sixth parameter type, sane for returned procedure
        `FP7` - function `before`'s seventh parameter type, sane for returned procedure
        `FP8` - function `before`'s seventh parameter type, sane for returned procedure
        `FP9` - function `before`'s ninth parameter type, sane for returned procedure
      Parameters:
        `before` - function to apply first, has to return a non-`null` result so unpacking the parameters from the tuple is possible
      Returns:
        chain of the given function and this procedure

    - #### from

          @NotNull
          static <T1,T2> Procedure2<T1,T2> from(@NotNull
                                                         java.util.function.BiConsumer<T1,T2> bico)

      Make a `BiConsumer` usable as a `Procedure2`. This is eg useful if you want to use partial.
      Type Parameters:
        `T1` - type of first argument
        `T2` - type of second argument
      Parameters:
        `bico` - biconsumer
      Returns:
        `Procedure2` view of the biconsumer

    - #### empty

          @NotNull
          static <T1,T2> Procedure2<T1,T2> empty()

      Return a procedure which does nothing. This just returns `NULL`, but the compiler will accept it smoothly.
      Specified by:
        `empty` in interface `Procedure1<ITuple2<? extends P1,? extends P2>>`
      Type Parameters:
        `T1` - first argument type
        `T2` - second argument type
      Returns:
        do-nothing procedure

    - #### nonFragile

          @NotNull
          static <E extends java.lang.Exception,PP1,PP2> Procedure2<PP1,PP2> nonFragile(@NotNull
                                                                                                 FragileProcedure2<E,? super PP1,? super PP2> fragileProc)

      Convert a 2-argument procedure which might throw a checked exception into one which does throw an unchecked exception. The returned function will instead throw an unchecked `WrappedFragileException` for any checked exception thrown during `Procedure1.apply(Object)`.
      Type Parameters:
        `E` - exception type
        `PP1` - type of first parameter
        `PP2` - type of second parameter
      Parameters:
        `fragileProc` - procedure throwing a checked exception
      Returns:
        non-fragile procedure

    - #### nonFragileX

          @NotNull
          static <E extends java.lang.Exception,PP1,PP2> Procedure2<PP1,PP2> nonFragileX(@NotNull
                                                                                                  FragileProcedure2<E,? super PP1,? super PP2> fragileProc,
                                                                                                  @NotNull
                                                                                                  Procedure3<? super E,? super PP1,? super PP2> exceptionHandler)

      Convert a 2-argument procedure which might throw a checked exception into one for which you can decide what happens with the exception. The exception handler allows
      - throw an unchecked exception instead (compare `nonFragile(FragileProcedure2)`)
      - do nothing
      - include logging in one of the above
      - and more...
      Type Parameters:
        `E` - exception type
        `PP1` - type of first parameter
        `PP2` - type of second parameter
      Parameters:
        `fragileProc` - procedure throwing a checked exception
        `exceptionHandler` - exception handler. Its return value will be used as return value of the returned function.
      Returns:
        non-fragile function