Interface CheckedFunction<T,R,E extends Throwable>

Type Parameters:
T - function argument type
R - function result type
E - exception type
All Superinterfaces:
Function<T,R>
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 CheckedFunction<T,R,E extends Throwable> extends Function<T,R>
Extension of Function that allows to throw checked exception.
  • Method Summary

    Modifier and Type
    Method
    Description
    default R
    apply(T t)
    Overrides Function.apply(Object) method to allow calling functions that throw checked exceptions.
    Applies function to the given argument.

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Method Details

    • apply

      default R apply(T t)
      Overrides Function.apply(Object) method to allow calling functions that throw checked exceptions. Is useful when used in methods that accept Function. For example: Map.computeIfAbsent(Object, Function).
      Specified by:
      apply in interface Function<T,R>
      Parameters:
      t - the function argument
      Returns:
      the function result
    • applyAndThrow

      R applyAndThrow(T t) throws E
      Applies function to the given argument.
      Parameters:
      t - the function argument
      Returns:
      the function result
      Throws:
      E - exception in case of errors