Interface SupplierEx<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 SupplierEx<T>
Represents a Supplier capable of throwing exceptions
  • Method Details

    • get

      T get() throws Exception
      Throws:
      Exception
    • of

      static <T> SupplierEx<T> of(Supplier<T> uncheckedFn)
      Creates a SupplierEx out of Supplier

      If given supplier throws UncheckedException, its cause will be propagated

      Parameters:
      uncheckedFn - original Supplier
      Returns:
      a supplier capable of throwing exceptions
    • uncheckedOf

      static <T> Supplier<T> uncheckedOf(SupplierEx<T> checkedFn)
      Creates a Supplier out of SupplierEx

      If given supplier throws a checked exception, it will be wrapped into UncheckedException and rethrown

      Unchecked exceptions will be handled by thread's FatalErrorHandler

      Parameters:
      checkedFn - original SupplierEx
      Returns:
      a supplier