Uses of Interface
java.util.function.Supplier
-
Packages that use Supplier Package Description java.lang Provides classes that are fundamental to the design of the Java programming language.java.util Contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).java.util.concurrent Utility classes commonly useful in concurrent programming.java.util.logging Provides the classes and interfaces of the JavaTM 2 platform's core logging facilities.java.util.stream Classes to support functional-style operations on streams of elements, such as map-reduce transformations on collections. -
-
Uses of Supplier in java.lang
Methods in java.lang with parameters of type Supplier Modifier and Type Method and Description static <S> ThreadLocal<S>
ThreadLocal. withInitial(Supplier<? extends S> supplier)
Creates a thread local variable. -
Uses of Supplier in java.util
Methods in java.util with parameters of type Supplier Modifier and Type Method and Description T
Optional. orElseGet(Supplier<? extends T> other)
Return the value if present, otherwise invokeother
and return the result of that invocation.<X extends Throwable>
TOptional. orElseThrow(Supplier<? extends X> exceptionSupplier)
Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.<X extends Throwable>
longOptionalLong. orElseThrow(Supplier<X> exceptionSupplier)
Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.<X extends Throwable>
doubleOptionalDouble. orElseThrow(Supplier<X> exceptionSupplier)
Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.<X extends Throwable>
intOptionalInt. orElseThrow(Supplier<X> exceptionSupplier)
Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.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. -
Uses of Supplier in java.util.concurrent
Methods in java.util.concurrent with parameters of type Supplier Modifier and Type Method and Description 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
Methods in java.util.logging with parameters of type Supplier Modifier and Type Method and Description void
Logger. config(Supplier<String> msgSupplier)
Log a CONFIG message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. fine(Supplier<String> msgSupplier)
Log a FINE message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. finer(Supplier<String> msgSupplier)
Log a FINER message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. finest(Supplier<String> msgSupplier)
Log a FINEST message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. info(Supplier<String> msgSupplier)
Log a INFO message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. log(Level level, Supplier<String> msgSupplier)
Log a message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. log(Level level, Throwable thrown, Supplier<String> msgSupplier)
Log a lazily constructed message, with associated Throwable information.void
Logger. logp(Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier)
Log a lazily constructed message, specifying source class and method, with no arguments.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
Logger. severe(Supplier<String> msgSupplier)
Log a SEVERE message, which is only to be constructed if the logging level is such that the message will actually be logged.void
Logger. warning(Supplier<String> msgSupplier)
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
Methods in java.util.stream that return Supplier Modifier and Type Method and Description Supplier<A>
Collector. supplier()
A function that creates and returns a new mutable result container.Methods in java.util.stream with parameters of type Supplier Modifier and Type Method and Description <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.<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.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>
Stream. generate(Supplier<T> s)
Returns an infinite sequential unordered stream where each element is generated by the providedSupplier
.static <T,K,D,A,M extends Map<K,D>>
Collector<T,?,M>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> mapSupplier)
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.static <T,K,U,M extends Map<K,U>>
Collector<T,?,M>Collectors. toMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapSupplier)
Returns aCollector
that accumulates elements into aMap
whose keys and values are the result of applying the provided mapping functions to the input elements.
-
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2022, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.