Class Suppliers

    • Method Detail

      • memoize

        public static final <R> Supplier<R> memoize​(Supplier<? extends R> s,
                                                    long durationNanos)
        Memoizes the supplied Supplier for a time equal to that represented by the supplied number of nanoseconds and returns the memoization.

        The memoization will not call the supplied Supplier's get() method until its own get() method is called.

        Type Parameters:
        R - the return type of the supplied Supplier
        Parameters:
        s - the Supplier to memoize; must not be null
        durationNanos - the duration, in nanoseconds, expressing how long the memoization will survive
        Returns:
        a memoized version of the supplied Supplier; never null
        Throws:
        NullPointerException - if either argument is null