public class CachingSupplier<T> extends Object implements Supplier<T>, Serializable
Modifier and Type | Method and Description |
---|---|
T |
get() |
static <T> CachingSupplier<T> |
of(Supplier<T> supplier)
Factory method for a
CachingSupplier that delegates to the given supplier when asked to supply a
value. |
static <T> CachingSupplier<T> |
of(T value)
Factory method for a
CachingSupplier that will supply the given value . |
public static <T> CachingSupplier<T> of(T value)
CachingSupplier
that will supply the given value
.
This factory method should be used when the value is already available. Used this way this supplier can be serialized.
T
- the type of results supplied by this suppliervalue
- the value to supplyCachingSupplier
that supplies the given valuepublic static <T> CachingSupplier<T> of(Supplier<T> supplier)
CachingSupplier
that delegates to the given supplier
when asked to supply a
value. If the given supplier
is a CachingSupplier
the instance is returned as is, if not a new
CachingSupplier
instance is created.T
- the type of results supplied by this suppliersupplier
- supplier for which to cache the resultCachingSupplier
based on given supplier
Copyright © 2010–2020. All rights reserved.