Uses of Interface
java.util.function.Supplier
Package
Description
Provides classes that are fundamental to the design of the Java
programming language.
Classes to support module descriptors and creating configurations of modules
by means of resolution and service binding.
HTTP Client and WebSocket APIs
Contains the collections framework, some internationalization support classes,
a service loader, properties, random number generation, string parsing
and scanning classes, base64 encoding and decoding, a bit array, and
several miscellaneous utility classes.
Utility classes commonly useful in concurrent programming.
Provides the classes and interfaces of
the Java 2 platform's core logging facilities.
Classes to support functional-style operations on streams of elements, such
as map-reduce transformations on collections.
Contains interfaces and classes needed by language runtimes to implement
their own language-specific object models and type conversions.
Provides interfaces for creating tools, such as a Read-Eval-Print Loop (REPL),
which interactively evaluate "snippets" of Java programming language code.
-
Uses of Supplier in java.lang
Modifier and TypeMethodDescriptiondefault void
System.Logger.log
(System.Logger.Level level, Supplier<String> msgSupplier) Logs a lazily supplied message.default void
System.Logger.log
(System.Logger.Level level, Supplier<String> msgSupplier, Throwable thrown) Logs a lazily supplied message associated with a given throwable.static <S> ThreadLocal<S>
ThreadLocal.withInitial
(Supplier<? extends S> supplier) Creates a thread local variable. -
Uses of Supplier in java.lang.module
Modifier and TypeMethodDescriptionstatic ModuleDescriptor
ModuleDescriptor.read
(InputStream in, Supplier<Set<String>> packageFinder) Reads the binary form of a module declaration from an input stream as a module descriptor.static ModuleDescriptor
ModuleDescriptor.read
(ByteBuffer bb, Supplier<Set<String>> packageFinder) Reads the binary form of a module declaration from a byte buffer as a module descriptor. -
Uses of Supplier in java.net.http
Modifier and TypeMethodDescriptionstatic HttpRequest.BodyPublisher
HttpRequest.BodyPublishers.ofInputStream
(Supplier<? extends InputStream> streamSupplier) A request body publisher that reads its data from anInputStream
. -
Uses of Supplier in java.util
Modifier and TypeInterfaceDescriptionstatic interface
Represents a service provider located byServiceLoader
.Modifier and TypeMethodDescriptionIf a value is present, returns anOptional
describing the value, otherwise returns anOptional
produced by the supplying function.If a value is present, returns the value, otherwise returns the result produced by the supplying function.Optional.orElseThrow
(Supplier<? extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.<X extends Throwable>
doubleOptionalDouble.orElseThrow
(Supplier<? extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.<X extends Throwable>
intOptionalInt.orElseThrow
(Supplier<? extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.<X extends Throwable>
longOptionalLong.orElseThrow
(Supplier<? extends X> exceptionSupplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.static <T> T
Objects.requireNonNull
(T obj, Supplier<String> messageSupplier) Checks that the specified object reference is notnull
and throws a customizedNullPointerException
if it is.static <T> T
Objects.requireNonNullElseGet
(T obj, Supplier<? extends T> supplier) Returns the first argument if it is non-null
and otherwise returns the non-null
value ofsupplier.get()
. -
Uses of Supplier in java.util.concurrent
Modifier and TypeMethodDescriptionCompletableFuture.completeAsync
(Supplier<? extends T> supplier) Completes this CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the default executor.CompletableFuture.completeAsync
(Supplier<? extends T> supplier, Executor executor) Completes this CompletableFuture with the result of the given Supplier function invoked from an asynchronous task using the given executor.static <U> CompletableFuture<U>
CompletableFuture.supplyAsync
(Supplier<U> supplier) Returns a new CompletableFuture that is asynchronously completed by a task running in theForkJoinPool.commonPool()
with the value obtained by calling the given Supplier.static <U> CompletableFuture<U>
CompletableFuture.supplyAsync
(Supplier<U> supplier, Executor executor) Returns a new CompletableFuture that is asynchronously completed by a task running in the given executor with the value obtained by calling the given Supplier. -
Uses of Supplier in java.util.logging
Modifier and TypeMethodDescriptionvoid
Log a CONFIG message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a FINE message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a FINER message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a FINEST message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a INFO message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a lazily constructed message, with associated Throwable information.void
Log a message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger.logp
(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier) Log a lazily constructed message, specifying source class and method, with associated Throwable information.void
Log a lazily constructed message, specifying source class and method, with no arguments.void
Log a SEVERE message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Log a WARNING message, which is only to be constructed if the logging level is such that the message will actually be logged. -
Uses of Supplier in java.util.stream
Modifier and TypeMethodDescriptionCollector.supplier()
A function that creates and returns a new mutable result container.Modifier and TypeMethodDescription<R> R
DoubleStream.collect
(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this stream.<R> R
IntStream.collect
(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this stream.<R> R
LongStream.collect
(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this stream.<R> R
Stream.collect
(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this stream.static DoubleStream
StreamSupport.doubleStream
(Supplier<? extends Spliterator.OfDouble> supplier, int characteristics, boolean parallel) Creates a new sequential or parallelDoubleStream
from aSupplier
ofSpliterator.OfDouble
.static <T> Stream<T>
Returns an infinite sequential unordered stream where each element is generated by the providedSupplier
.Collectors.groupingBy
(Function<? super T, ? extends K> classifier, Supplier<M> mapFactory, Collector<? super T, A, D> downstream) Returns aCollector
implementing a cascaded "group by" operation on input elements of typeT
, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstreamCollector
.static <T,
K, A, D, M extends ConcurrentMap<K, D>>
Collector<T,?, M> Collectors.groupingByConcurrent
(Function<? super T, ? extends K> classifier, Supplier<M> mapFactory, Collector<? super T, A, D> downstream) Returns a concurrentCollector
implementing a cascaded "group by" operation on input elements of typeT
, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstreamCollector
.static IntStream
StreamSupport.intStream
(Supplier<? extends Spliterator.OfInt> supplier, int characteristics, boolean parallel) Creates a new sequential or parallelIntStream
from aSupplier
ofSpliterator.OfInt
.static LongStream
StreamSupport.longStream
(Supplier<? extends Spliterator.OfLong> supplier, int characteristics, boolean parallel) Creates a new sequential or parallelLongStream
from aSupplier
ofSpliterator.OfLong
.static <T,
A, R> Collector<T, A, R> Collector.of
(Supplier<A> supplier, BiConsumer<A, T> accumulator, BinaryOperator<A> combiner, Function<A, R> finisher, Collector.Characteristics... characteristics) Returns a newCollector
described by the givensupplier
,accumulator
,combiner
, andfinisher
functions.static <T,
R> Collector<T, R, R> Collector.of
(Supplier<R> supplier, BiConsumer<R, T> accumulator, BinaryOperator<R> combiner, Collector.Characteristics... characteristics) Returns a newCollector
described by the givensupplier
,accumulator
, andcombiner
functions.static <T> Stream<T>
StreamSupport.stream
(Supplier<? extends Spliterator<T>> supplier, int characteristics, boolean parallel) Creates a new sequential or parallelStream
from aSupplier
ofSpliterator
.static <T,
C extends Collection<T>>
Collector<T,?, C> Collectors.toCollection
(Supplier<C> collectionFactory) Returns aCollector
that accumulates the input elements into a newCollection
, in encounter order.static <T,
K, U, M extends ConcurrentMap<K, U>>
Collector<T,?, M> Collectors.toConcurrentMap
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory) Returns a concurrentCollector
that accumulates elements into aConcurrentMap
whose keys and values are the result of applying the provided mapping functions to the input elements.Collectors.toMap
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory) Returns aCollector
that accumulates elements into aMap
whose keys and values are the result of applying the provided mapping functions to the input elements. -
Uses of Supplier in jdk.dynalink.linker
Modifier and TypeClassDescriptionclass
A class acting as a supplier of guarding dynamic linkers that can be automatically loaded by other language runtimes.Modifier and TypeMethodDescriptionGuardingTypeConverterFactory.convertToType
(Class<?> sourceType, Class<?> targetType, Supplier<MethodHandles.Lookup> lookupSupplier) Returns a guarded type conversion that receives a value of the specified source type and returns a value converted to the specified target type.<T> T
LinkerServices.getWithLookup
(Supplier<T> operation, SecureLookupSupplier lookupSupplier) Executes an operation within the context of a particularMethodHandles.Lookup
lookup object. -
Uses of Supplier in jdk.jshell
Modifier and TypeMethodDescriptionJShell.Builder.tempVariableNameGenerator
(Supplier<String> generator) Sets a generator of temp variable names forVarSnippet
ofSnippet.SubKind.TEMP_VAR_EXPRESSION_SUBKIND
.