- java.lang.Object
-
- org.omnifaces.utils.stream.Collectors
-
public final class Collectors extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R1,R2>
Collector<T,?,Map.Entry<R1,R2>>combine(Collector<T,?,R1> collector1, Collector<T,?,R2> collector2)
static <T> Collector<T,?,Optional<T>>
findLast()
Returns a collector which will return the last element of a stream, if present.static <T> Collector<T,?,Void>
forEachBatch(Consumer<List<T>> batchConsumer, int batchSize)
static <T> Collector<T,?,Stream<T>>
reversedStream()
Returns a collector which takes the elements of the current stream and returns a new stream with the same elements in reverse order.static <T extends Comparable<T>>
Collector<T,?,Summary<T>>summary()
static <T> Collector<T,?,Summary<T>>
summaryBy(Comparator<? super T> comparator)
static <T,K>
Collector<T,?,Map<K,T>>toLinkedMap(Function<? super T,? extends K> keyMapper)
static <T> Collector<T,?,Set<T>>
toLinkedSet()
static <T,K>
Collector<T,?,Map<K,T>>toMap(Function<? super T,? extends K> keyMapper)
-
-
-
Method Detail
-
toMap
public static <T,K> Collector<T,?,Map<K,T>> toMap(Function<? super T,? extends K> keyMapper)
-
toLinkedMap
public static <T,K> Collector<T,?,Map<K,T>> toLinkedMap(Function<? super T,? extends K> keyMapper)
-
forEachBatch
public static <T> Collector<T,?,Void> forEachBatch(Consumer<List<T>> batchConsumer, int batchSize)
-
combine
public static <T,R1,R2> Collector<T,?,Map.Entry<R1,R2>> combine(Collector<T,?,R1> collector1, Collector<T,?,R2> collector2)
-
reversedStream
public static <T> Collector<T,?,Stream<T>> reversedStream()
Returns a collector which takes the elements of the current stream and returns a new stream with the same elements in reverse order.This collector will collect all elements from a stream into memory in order to return the reversed stream. As a result this collector may not be suitable for extremely large or infinite streams.
- Type Parameters:
T
- The type of the elements- Returns:
- A Collector that returns the elements of a stream in reverse order.
-
findLast
public static <T> Collector<T,?,Optional<T>> findLast()
Returns a collector which will return the last element of a stream, if present.- Type Parameters:
T
- The type of the elements- Returns:
- An
Optional
containing the last element of the stream orOptional.empty()
if the stream is empty.
-
summary
public static <T extends Comparable<T>> Collector<T,?,Summary<T>> summary()
-
summaryBy
public static <T> Collector<T,?,Summary<T>> summaryBy(Comparator<? super T> comparator)
-
-