de.caff.generics.function

## Interface Procedure1<P>

- Type Parameters:
    `P` - parameter type
  All Superinterfaces:
    java.util.function.Consumer<P>
  All Known Subinterfaces:
    Procedure2<P1,P2>, Procedure3<P1,P2,P3>, Procedure4<P1,P2,P3,P4>, Procedure5<P1,P2,P3,P4,P5>, Procedure6<P1,P2,P3,P4,P5,P6>, Procedure7<P1,P2,P3,P4,P5,P6,P7>, Procedure8<P1,P2,P3,P4,P5,P6,P7,P8>, Procedure9<P1,P2,P3,P4,P5,P6,P7,P8,P9>
  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 Procedure1<P>
      extends java.util.function.Consumer<P>

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Procedure1<?>` | `NULL` Procedure with one argument which does nothing.

  - ### Method Summary

    All Methods Static Methods Instance Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default void` | `apply(P arg)` Run the function.
    `default void` | `applyNonNull(P argument)` Apply this procedure only if the argument is not `null`.
    `static <T> Procedure1<T>` | `empty()` Return a procedure which does nothing.
    `static <T> Procedure1<T>` | `from(java.util.function.Consumer<T> consumer)` Make a `Consumer` usable as a `Procedure1`.
    `static <E extends java.lang.Exception,PP> Procedure1<PP>` | `nonFragile(FragileProcedure1<E,? super PP> fragileProc)` Convert a 1-argument procedure which might throw a checked exception into one which does throw an unchecked exception.
    `static <E extends java.lang.Exception,PP> Procedure1<PP>` | `nonFragileX(FragileProcedure1<E,? super PP> fragileProc, java.util.function.BiConsumer<? super E,? super PP> exceptionHandler)` Convert a 1-argument procedure which might throw a checked exception into one for which you can decide what happens with the exception.
    `default Procedure0` | `partial(P argument)` Return a partial evaluation of this procedure.

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

      `accept, andThen`

- - ### Field Detail

    - #### NULL

          @NotNull
          static final Procedure1<?> NULL

      Procedure with one argument which does nothing. Use `empty()` instead.

  - ### Method Detail

    - #### apply

          default void apply(P arg)

      Run the function.
      Parameters:
        `arg` - function argument

    - #### applyNonNull

          default void applyNonNull(@Nullable
                                    P argument)

      Apply this procedure only if the argument is not `null`.

      Using this invocation it is guaranteed that `apply(Object)` will always be called with a non-null argument.

      Use `Types.notNull(Object, Object)` if yo want to invoke this with a default argument when `argument` is `null`.

      Parameters:
        `argument` - argument of this function, possibly `null`

    - #### partial

          @NotNull
          default Procedure0 partial(P argument)

      Return a partial evaluation of this procedure.
      Parameters:
        `argument` - constant argument use for the evaluation
      Returns:
        zero argument procedure

    - #### from

          @NotNull
          static <T> Procedure1<T> from(@NotNull
                                                 java.util.function.Consumer<T> consumer)

      Make a `Consumer` usable as a `Procedure1`.
      Type Parameters:
        `T` - argument type of both
      Parameters:
        `consumer` - consumer
      Returns:
        `Procedure1` view of the given consumer

    - #### empty

          @NotNull
          static <T> Procedure1<T> empty()

      Return a procedure which does nothing. This just returns `NULL`, but the compiler will accept it smoothly.
      Type Parameters:
        `T` - argument type
      Returns:
        do-nothing procedure

    - #### nonFragile

          @NotNull
          static <E extends java.lang.Exception,PP> Procedure1<PP> nonFragile(@NotNull
                                                                                       FragileProcedure1<E,? super PP> fragileProc)

      Convert a 1-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 `apply(Object)`.
      Type Parameters:
        `E` - exception type
        `PP` - parameter type
      Parameters:
        `fragileProc` - procedure throwing a checked exception
      Returns:
        non-fragile procedure

    - #### nonFragileX

          @NotNull
          static <E extends java.lang.Exception,PP> Procedure1<PP> nonFragileX(@NotNull
                                                                                        FragileProcedure1<E,? super PP> fragileProc,
                                                                                        @NotNull
                                                                                        java.util.function.BiConsumer<? super E,? super PP> exceptionHandler)

      Convert a 1-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(FragileProcedure1)`)
      - do nothing
      - include logging in one of the above
      - and more...
      Type Parameters:
        `E` - exception type
        `PP` - parameter type
      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