de.caff.generics

## Interface Copier<T>

- All Superinterfaces:
    java.util.function.Function<T,T>, Function1<T,T>
  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 Copier<T>
      extends Function1<T,T>

  Get copies of items of a given class.
  Since:
    September 29, 2020
  Author:
    Rammi

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default T` | `apply(T t)` Apply this as a function.
    `T` | `copy(T item)` Get a copy of the given item.
    `static <U> U` | `getCopy(Copier<U> copier, U item)` Get a copy of the given item while taking care of `null` values.
    `default T` | `nullableCopy(T item)` Get a copy of the given item even if it is `null`.

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

      `after, andThen, applyNonNull, applyOrDefault, fallback, fallback, from, from, nonFragile, nonFragile, nonFragileX, partial, withFallback`

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

      `compose, identity`

- - ### Method Detail

    - #### copy

          @NotNull
          T copy(@NotNull
                          T item)

      Get a copy of the given item. Implementations may expect item not to be `null`, callers will have to take care of that. See `nullableCopy(Object)` and `getCopy(Copier, Object)` which help in cases where `null` items may appear.
      Parameters:
        `item` - item to be copied
      Returns:
        copy of the given item

    - #### apply

          default T apply(T t)

      Apply this as a function. This takes care of possible `null` items.
      Specified by:
        `apply` in interface `java.util.function.Function<T,T>`
      Parameters:
        `t` - item to be copied, possibly `null`
      Returns:
        copied item, `null` if `t` was `null`

    - #### nullableCopy

          @Nullable
          default T nullableCopy(@Nullable
                                           T item)

      Get a copy of the given item even if it is `null`.
      Parameters:
        `item` - item to be copied, possibly `null`
      Returns:
        copier item, `null` if item was `null`

    - #### getCopy

          @Nullable
          static <U> U getCopy(@NotNull
                                         Copier<U> copier,
                                         @Nullable
                                         U item)

      Get a copy of the given item while taking care of `null` values.
      Type Parameters:
        `U` - item type
      Parameters:
        `copier` - copier to apply to non-`null` items
        `item` - item to be copied, possibly `null`
      Returns:
        copied item, or `null` if item was `null`