Class FilterStreamUtils


  • public final class FilterStreamUtils
    extends Object

    Class that contains different filter helper functions for Streams

    Since:
    2.0
    Author:
    Andreas Pointner
    • Method Detail

      • distinctByKeys

        @SafeVarargs
        public static <T> Predicate<T> distinctByKeys​(Function<? super T,​?>... keyExtractors)

        Method that helps to distinct a stream by multiple properties

             Stream<Xyz> s = ...;
             Stream<Xyz> sDistinct = s.filter(FilterStreamUtils.distinctByKeys(Xyz::getAbc, Xyz::getDef, ...));
         
        Type Parameters:
        T - the type of the class of the stream
        Parameters:
        keyExtractors - array of key extractor functions
        Returns:
        a predicate that is used inside filter methods of streams.
        See Also:
        Java 8 stream distinct by multiple fields