Interface IThrowingSupplier<T>

  • Type Parameters:
    T - the type of results supplied by this supplier
    All Superinterfaces:
    ITypedThrowingSupplier<T,​Exception>, 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 IThrowingSupplier<T>
    extends ITypedThrowingSupplier<T,​Exception>
    A Supplier that may throw a checked exception.

    Represents a supplier of results.

    There is no requirement that a new or distinct result be returned each time the supplier is invoked.

    This is a functional interface whose functional method is tryGet().

    Since:
    8.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • of

        static <T> IThrowingSupplier<T> of​(IThrowingSupplier<T> supplier)
        Returns the given supplier, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:
         final var supplier = IThrowingSupplier.of(t -> ...);
        
         
        Type Parameters:
        T - the type of results supplied by this supplier
        Parameters:
        supplier - Supplier to return.
        Returns:
        The given supplier.