Class FilterUtil


  • public class FilterUtil
    extends java.lang.Object
    Author:
    Sergey.Anchipolevsky Date: 20.08.2007
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Filter<T> and​(Filter<? super T>... filters)  
      static <C extends java.util.Collection<? super T>,​T>
      C
      filterAndCopy​(java.lang.Iterable<T> source, C target, Filter<? super T> filter)
      Applies filter to the source collection and adds accepted values to the target collection.
      static <E,​T extends E>
      java.util.ArrayList<T>
      filterArrayList​(java.util.ArrayList<T> original, Filter<E> filter)
      Optimized filtering of ArrayLists.
      static <E,​T extends java.util.Collection<? extends E>>
      T
      filterCollection​(T collection, Filter<E> filter)
      Deletes from the given collection all elements that aren't accepted by the given filter
      static <Key,​Value,​T extends java.util.Map<Key,​Value>>
      T
      filterMapByKey​(T map, Filter<? super Key> filter)  
      static <Key,​Value,​Source extends java.util.Map<? extends Key,​? extends Value>,​Target extends java.util.Map<? super Key,​? super Value>>
      Target
      filterMapByKeyAndCopy​(Source sourceMap, Target targetMap, Filter<? super Key> filter)  
      static <Key,​Value,​T extends java.util.Map<Key,​Value>>
      T
      filterMapByValue​(T map, Filter<Value> filter)
      Filters map with help of value filter.
      static <T> Filter<T> not​(Filter<T> filter)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.util.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> java.util.ArrayList<T> filterArrayList​(@NotNull
                                                                                   java.util.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 java.util.Map<Key,​Value>> T filterMapByKey​(@NotNull
                                                                                                        T map,
                                                                                                        @NotNull
                                                                                                        Filter<? super Key> filter)
      • filterMapByValue

        public static <Key,​Value,​T extends java.util.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 java.util.Map<? extends Key,​? extends Value>,​Target extends java.util.Map<? super Key,​? super Value>> Target filterMapByKeyAndCopy​(@NotNull
                                                                                                                                                                                                                 Source sourceMap,
                                                                                                                                                                                                                 @NotNull
                                                                                                                                                                                                                 Target targetMap,
                                                                                                                                                                                                                 @NotNull
                                                                                                                                                                                                                 Filter<? super Key> filter)
      • filterAndCopy

        public static <C extends java.util.Collection<? super T>,​T> C filterAndCopy​(@NotNull
                                                                                          java.lang.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