Package org.springframework.data.util
Interface StreamUtils
public interface StreamUtils
Spring Data specific Java
Stream
utility methods and classes.- Since:
- 1.10
- Author:
- Thomas Darimont, Oliver Gierke
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Stream<T>
createStreamFromIterator
(Iterator<T> iterator) static <T> Stream<T>
createStreamFromIterator
(CloseableIterator<T> iterator) Returns aStream
backed by the givenCloseableIterator
and forwarding calls toBaseStream.close()
to the iterator.static <T> Stream<T>
fromNullable
(T source) static <T,
K, V> Collector<T, MultiValueMap<K, V>, MultiValueMap<K, V>> toMultiMap
(Function<T, K> keyFunction, Function<T, V> valueFunction) Returns aCollector
to create aMultiValueMap
.static <L,
R, T> Stream<T> zip
(Stream<L> left, Stream<R> right, BiFunction<L, R, T> combiner) Zips the givenStream
s using the givenBiFunction
.
-
Method Details
-
createStreamFromIterator
- Parameters:
iterator
- must not be null.- Returns:
-
createStreamFromIterator
Returns aStream
backed by the givenCloseableIterator
and forwarding calls toBaseStream.close()
to the iterator.- Parameters:
iterator
- must not be null.- Returns:
- Since:
- 2.0
-
toUnmodifiableList
- Returns:
- will never be null.
-
toUnmodifiableSet
- Returns:
- will never be null.
-
toMultiMap
static <T,K, Collector<T,V> MultiValueMap<K, toMultiMapV>, MultiValueMap<K, V>> (Function<T, K> keyFunction, Function<T, V> valueFunction) Returns aCollector
to create aMultiValueMap
. -
fromNullable
-
zip
Zips the givenStream
s using the givenBiFunction
. The resultingStream
will have the length of the shorter of the two, abbreviating the zipping when the shorter of the twoStream
s is exhausted.- Parameters:
left
- must not be null.right
- must not be null.combiner
- must not be null.- Returns:
- Since:
- 2.1
-