Interface ThrowableSupplier<T,X extends Throwable>

Type Parameters:
T - The return type
X - The exception that can be thrown
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 ThrowableSupplier<T,X extends Throwable>
Functional interface that takes no arguments and returns a value.
The FunctionalInterface method is get().
The class is equivalent to Supplier, but the functional method can throw a checked exception.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> @NotNull Supplier<T>
    caught(@NotNull ThrowableSupplier<T,? extends Throwable> supplier)
    Converts a throwable supplier into a supplier that throws a runtime exception when an exception is thrown.
    get()
    Returns the result of the supplier.
  • Method Details

    • caught

      @NotNull static <T> @NotNull Supplier<T> caught(@NotNull @NotNull ThrowableSupplier<T,? extends Throwable> supplier)
      Converts a throwable supplier into a supplier that throws a runtime exception when an exception is thrown.
      Type Parameters:
      T - The type of the result
      Parameters:
      supplier - The throwable supplier
      Returns:
      A caught supplier
      Throws:
      NullPointerException - If the throwable supplier is null
    • get

      T get() throws X
      Returns the result of the supplier.
      Returns:
      The result
      Throws:
      X - The exception that can be thrown