@GwtCompatible public interface Supplier<T>
java.util.function.Supplier
. Semantically, this could be a factory,
generator, builder, closure, or something else entirely. No guarantees are implied by this
interface.
The Suppliers
class provides common suppliers and related utilities.
See the Guava User Guide article on the use of functional types.
This interface is now a legacy type. Use java.util.function.Supplier
(or the
appropriate primitive specialization such as IntSupplier
) instead whenever possible.
Otherwise, at least reduce explicit dependencies on this type by using lambda expressions
or method references instead of classes, leaving your code easier to migrate in the future.
To use an existing supplier instance (say, named supplier
) in a context where the
other type of supplier is expected, use the method reference supplier::get
. A
future version of com.google.common.base.Supplier
will be made to extend java.util.function.Supplier
, making conversion code necessary only in one direction. At that
time, this interface will be officially discouraged.
Modifier and Type | Method and Description |
---|---|
T |
get()
Retrieves an instance of the appropriate type.
|
@CanIgnoreReturnValue T get()
Copyright © 2010–2017. All rights reserved.