Class FilterUtil


  • public class FilterUtil
    extends Object
    Author:
    Sergey.Anchipolevsky Date: 20.08.2007
    • Method Detail

      • not

        @NotNull
        public static <T> Filter<T> not​(@NotNull
                                        Filter<T> filter)
      • and

        @NotNull
        public static <T> Filter<T> and​(@NotNull
                                        Filter<? super T>... filters)
      • filterCollection

        public static <E,​T extends Collection<? extends E>> T filterCollection​(@NotNull
                                                                                     T collection,
                                                                                     @NotNull
                                                                                     Filter<E> filter)
        Deletes from the given collection all elements that aren't accepted by the given filter
        Parameters:
        collection - modifiable collection.
        filter - the filter
        Returns:
        the source filtered collection for convenience
      • filterArrayList

        @NotNull
        public static <E,​T extends E> ArrayList<T> filterArrayList​(@NotNull
                                                                         ArrayList<T> original,
                                                                         @NotNull
                                                                         Filter<E> filter)
        Optimized filtering of ArrayLists.
        Parameters:
        original - original ArrayList
        filter - filter to be applied
        Returns:
        optimized filtering of ArrayList
      • filterMapByKey

        @NotNull
        public static <Key,​Value,​T extends Map<Key,​Value>> T filterMapByKey​(@NotNull
                                                                                              T map,
                                                                                              @NotNull
                                                                                              Filter<? super Key> filter)
      • filterMapByValue

        public static <Key,​Value,​T extends Map<Key,​Value>> T filterMapByValue​(@NotNull
                                                                                                T map,
                                                                                                @NotNull
                                                                                                Filter<Value> filter)
        Filters map with help of value filter. All values for which filter returns false are removed from the map.
        Parameters:
        map - map to process
        filter - filter
        Returns:
        same map object with some entries removed
        Since:
        7.1.1
      • filterMapByKeyAndCopy

        public static <Key,​Value,​Source extends Map<? extends Key,​? extends Value>,​Target extends Map<? super Key,​? super Value>> Target filterMapByKeyAndCopy​(@NotNull
                                                                                                                                                                                             Source sourceMap,
                                                                                                                                                                                             @NotNull
                                                                                                                                                                                             Target targetMap,
                                                                                                                                                                                             @NotNull
                                                                                                                                                                                             Filter<? super Key> filter)
      • filterAndCopy

        public static <C extends Collection<? super T>,​T> C filterAndCopy​(@NotNull
                                                                                Iterable<T> source,
                                                                                @NotNull
                                                                                C target,
                                                                                @NotNull
                                                                                Filter<? super T> filter)
        Applies filter to the source collection and adds accepted values to the target collection.
        Parameters:
        source - collection to filter
        target - collection where to add accepted objects
        filter - filter
        Returns:
        target collection