Interface CheckedSupplier<T,E extends Exception>

Type Parameters:
T - The return type of the lambda function.
E - The type of exception thrown by the lambda function.
All Superinterfaces:
Supplier<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 CheckedSupplier<T,E extends Exception> extends Supplier<T>
The java standard library does not provide a lambda function interface for functions that take no arguments, but that throw an exception. So, we have to define our own here.
  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    get()
     
    Gets a result.
  • Method Details

    • get

      default T get()
      Specified by:
      get in interface Supplier<T>
    • getAndThrow

      T getAndThrow() throws E
      Gets a result.
      Returns:
      a result
      Throws:
      E - exception in case of errors