Interface ISerializableThrowingSupplier<T>

  • Type Parameters:
    T - the type of results supplied by this supplier
    All Superinterfaces:
    Serializable, 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 ISerializableThrowingSupplier<T>
    extends Supplier<T>, Serializable
    A Supplier that is also serializable and can throw exceptions.

    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 get().

    Since:
    8.0.1
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • tryGet

        T tryGet()
          throws Exception
        Gets a result.
        Returns:
        The result
        Throws:
        Exception - When this operation fails.
      • get

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

        static <T> ISerializableThrowingSupplier<T> of​(ISerializableThrowingSupplier<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 = ISerializableThrowingSupplier.of(t -> ...);
         
         
        Type Parameters:
        T - the type of results supplied by this supplier
        Parameters:
        supplier - Supplier to return.
        Returns:
        The given supplier.