Class Suppliers


  • public final class Suppliers
    extends Object
    Utility functions for Supplier.
    • Method Detail

      • constant

        public static <T> Supplier<T> constant​(T t)
        Returns a constant supplier.
        Type Parameters:
        T - the type of the supplied value
        Parameters:
        t - the constant
        Returns:
        the constant supplier
      • mapping

        public static <U,​V> Supplier<V> mapping​(Function<? super U,​? extends V> mapper,
                                                      Supplier<U> supplier)
        Maps the output of an supplier using a function.
        Type Parameters:
        U - The original suppliers return type
        V - The new suppliers return type
        Parameters:
        supplier - the original supplier
        mapper - the mapper
        Returns:
        the new supplier
      • asFunction

        public static <U,​V> Function<U,​V> asFunction​(Supplier<V> supplier)
        Creates a function ignoring it's parameter and just returning the supplier's value.
        Type Parameters:
        U - the parameter type
        V - the supplier's return type
        Parameters:
        supplier - the supplier
        Returns:
        the function