Class Suppliers

    • Method Detail

      • memorize

        public static <T> Supplier<T> memorize​(Supplier<T> supplier)
        Returns a supplier which caches the result of the first call to Supplier.get()and returns that value on subsequent calls.
        Type Parameters:
        T - the type of results supplied by this supplier.
        Parameters:
        supplier - the delegate Supplier.
        Returns:
        the result fo the first call to the delegate's Supplier.get() method.
      • constant

        public static <T> Supplier<T> constant​(T value)
        Returns a supplier that return a constant value.
        Type Parameters:
        T - the type of results supplied by this supplier.
        Parameters:
        value - the constant value to return.
        Returns:
        the supplied value.
      • firstMatching

        public static <T> Optional<T> firstMatching​(Predicate<T> predicate,
                                                    ThrowingSupplier<T,​Exception>... suppliers)
                                             throws Exception
        Returns the first value provide by the given suppliers that matches the given predicate.
        Type Parameters:
        T - the type of results supplied by this supplier.
        Parameters:
        predicate - the predicate used to evaluate the computed values.
        suppliers - a list fo supplier.
        Returns:
        the optional matching value.
        Throws:
        Exception