Class Collectors

java.lang.Object
org.omnifaces.utils.stream.Collectors

public final class Collectors extends Object
  • Method Details

    • 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)
    • toLinkedSet

      public static <T> Collector<T,?,Set<T>> toLinkedSet()
    • 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 or Optional.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)