Interface ThrowingFunction<A,R,T extends Throwable>

Type Parameters:
A - The input argument type for the function
R - The output result type for the function
T - The type of Throwable thrown by the function
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 ThrowingFunction<A,R,T extends Throwable>
A better version of Java's Function interface that allows for the functions to throw whatever Throwable is specified.
Version:
0.1-Alpha-SNAPSHOT
Author:
Logan Ferree (Tadukoo)
  • Method Summary

    Modifier and Type
    Method
    Description
    default <S> ThrowingFunction<A,S,T>
    andThen(ThrowingFunction<? super R,? extends S,? extends T> after)
    Creates a ThrowingFunction that runs this ThrowingFunction and puts the result into the given ThrowingFunction.
    apply(A a)
    Takes a single argument and returns a result.
    default <S> ThrowingFunction<S,R,T>
    compose(ThrowingFunction<? super S,? extends A,? extends T> before)
    Creates a ThrowingFunction that runs the given ThrowingFunction and puts the result into this ThrowingFunction.
    static <A, T extends Throwable>
    ThrowingFunction<A,A,T>
    Returns a ThrowingFunction that always returns its input argument
  • Method Details

    • apply

      R apply(A a) throws T
      Takes a single argument and returns a result.
      Parameters:
      a - The argument
      Returns:
      A result
      Throws:
      T - Determined by the function, not required
    • compose

      default <S> ThrowingFunction<S,R,T> compose(ThrowingFunction<? super S,? extends A,? extends T> before)
      Creates a ThrowingFunction that runs the given ThrowingFunction and puts the result into this ThrowingFunction.
      Type Parameters:
      S - The input type to the composed ThrowingFunction
      Parameters:
      before - The ThrowingFunction to run before this one, and put the result into this one
      Returns:
      The ThrowingFunction made from composing this one and the given one
    • andThen

      default <S> ThrowingFunction<A,S,T> andThen(ThrowingFunction<? super R,? extends S,? extends T> after)
      Creates a ThrowingFunction that runs this ThrowingFunction and puts the result into the given ThrowingFunction.
      Type Parameters:
      S - The output type of the 2nd ThrowingFunction
      Parameters:
      after - A 2nd ThrowingFunction to put the result of this one into
      Returns:
      The ThrowingFunction made from composing this one and the given one
    • identity

      static <A, T extends Throwable> ThrowingFunction<A,A,T> identity()
      Returns a ThrowingFunction that always returns its input argument
      Type Parameters:
      A - The type of argument
      T - The Throwable being thrown
      Returns:
      A ThrowingFunction that always returns its input argument