Class StreamUtils

java.lang.Object
ch.tocco.nice2.toolbox.api.util.StreamUtils

public final class StreamUtils extends Object
  • Method Details

    • distinctByKey

      public static <T> Predicate<T> distinctByKey(Function<? super T,Object> keyExtractor)
    • uniqueByFunction

      public static <I, K> Collector<I,List<I>,List<I>> uniqueByFunction(Function<I,K> uniqueFunction)
      collects elements if the result of feeding them through a given function has not already been encountered the order of elements is preserved, so the first element for each occurrence is collected
      Type Parameters:
      I - the type of the stream
      K - the type of the result of the function
      Parameters:
      uniqueFunction - the function whose result should be checked for uniqueness
      Returns:
      the collector