Interface Joinable<D,R>

All Superinterfaces:
Function<D,R>

public interface Joinable<D,R> extends Function<D,R>
A joinable function

Usage

  Function<Person, String> nameProvider = Joinable
     .of (Person::getBoss)
     .add(Person::getBoss)
     .add(Person::getName);
  String superBossName = nameProvider.apply(getPerson());
 
Author:
Pavel Ponec
  • Method Summary

    Modifier and Type
    Method
    Description
    default <F> @Nullable Joinable<D,F>
    add(@NotNull Joinable<R,F> next)
    Send a result of the first function to the next one.
    apply(D d)
    Applies this function to the given argument.
    static <D, R> @NotNull Joinable<D,R>
    of(@NotNull Function<D,R> fce)
    Create a joinable function

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Method Details

    • apply

      @Nullable R apply(@Nullable D d)
      Applies this function to the given argument.
      Specified by:
      apply in interface Function<D,R>
      Parameters:
      d - The nullable function argument
      Returns:
      The function result
    • add

      @Nullable default <F> @Nullable Joinable<D,F> add(@NotNull @NotNull Joinable<R,F> next)
      Send a result of the first function to the next one.
      Type Parameters:
      F - A final result type
      Parameters:
      next - Next function
      Returns:
      If a result of the first function is null than the final result is null too.
    • of

      @NotNull static <D, R> @NotNull Joinable<D,R> of(@NotNull @NotNull Function<D,R> fce)
      Create a joinable function
      Type Parameters:
      D - Domain value
      R - Result value
      Parameters:
      fce - An original function
      Returns:
      The new object type of Function