## Uses of Interface
java.util.function.Supplier

- Packages that use Supplier
  Package | Description
  --- | ---
  java.util |
  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.util

    Methods in java.util with parameters of type Supplier
    Modifier and Type | Method and Description
    --- | ---
    `Optional<T>` | Optional.`or(Supplier<? extends Optional<? extends T>> supplier)` If a value is present, returns an `Optional` describing the value, otherwise returns an `Optional` produced by the supplying function.
    `T` | Optional.`orElseGet(Supplier<? extends T> supplier)` If a value is present, returns the value, otherwise returns the result produced by the supplying function.
    `<X extends Throwable> T` | 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> long` | OptionalLong.`orElseThrow(Supplier<X> exceptionSupplier)` Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.
    `<X extends Throwable> int` | OptionalInt.`orElseThrow(Supplier<X> exceptionSupplier)` Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.
    `<X extends Throwable> double` | OptionalDouble.`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 not `null` and throws a customized `NullPointerException` if it is.

  - ### 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 parallel `DoubleStream` from a `Supplier` of `Spliterator.OfDouble`.
    `static <T> Stream<T>` | Stream.`generate(Supplier<T> s)` Returns an infinite sequential unordered stream where each element is generated by the provided `Supplier`.
    `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 a `Collector` implementing a cascaded "group by" operation on input elements of type `T`, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream `Collector`.
    `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 concurrent `Collector` implementing a cascaded "group by" operation on input elements of type `T`, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream `Collector`.
    `static IntStream` | StreamSupport.`intStream(Supplier<? extends Spliterator.OfInt> supplier, int characteristics, boolean parallel)` Creates a new sequential or parallel `IntStream` from a `Supplier` of `Spliterator.OfInt`.
    `static LongStream` | StreamSupport.`longStream(Supplier<? extends Spliterator.OfLong> supplier, int characteristics, boolean parallel)` Creates a new sequential or parallel `LongStream` from a `Supplier` of `Spliterator.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 new `Collector` described by the given `supplier`, `accumulator`, `combiner`, and `finisher` 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 new `Collector` described by the given `supplier`, `accumulator`, and `combiner` functions.
    `static <T> Stream<T>` | StreamSupport.`stream(Supplier<? extends Spliterator<T>> supplier, int characteristics, boolean parallel)` Creates a new sequential or parallel `Stream` from a `Supplier` of `Spliterator`.
    `static <T,C extends Collection<T>> Collector<T,?,C>` | Collectors.`toCollection(Supplier<C> collectionFactory)` Returns a `Collector` that accumulates the input elements into a new `Collection`, 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 concurrent `Collector` that accumulates elements into a `ConcurrentMap` 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 a `Collector` that accumulates elements into a `Map` whose keys and values are the result of applying the provided mapping functions to the input elements.

Copyright © 2025 API Design. All Rights Reserved.