Class CollectionUtils


  • @Internal
    public final class CollectionUtils
    extends java.lang.Object
    Util class for Collections
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  CollectionUtils.Predicate<T>
      A simplified copy of Java 8 Predicate.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      @NotNull java.util.Map<K,​V>
      filterMapEntries​(@NotNull java.util.Map<K,​V> map, @NotNull CollectionUtils.Predicate<java.util.Map.Entry<K,​V>> predicate)
      Returns a new map which entries match a predicate specified by a parameter.
      static <T> @Nullable java.util.List<T> newArrayList​(@Nullable java.util.List<T> list)
      Creates a new ArrayList as a shallow copy of list given by parameter.
      static <K,​V>
      @Nullable java.util.Map<K,​@NotNull V>
      newConcurrentHashMap​(@Nullable java.util.Map<K,​@NotNull V> map)
      Creates a new ConcurrentHashMap as a shallow copy of map given by parameter.
      static <K,​V>
      @Nullable java.util.Map<K,​@NotNull V>
      newHashMap​(@Nullable java.util.Map<K,​@NotNull V> map)
      Creates a new HashMap as a shallow copy of map given by parameter.
      static int size​(@NotNull java.lang.Iterable<?> data)
      Returns an Iterator size
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • size

        public static int size​(@NotNull
                               @NotNull java.lang.Iterable<?> data)
        Returns an Iterator size
        Parameters:
        data - the Iterable
        Returns:
        iterator size
      • newConcurrentHashMap

        @Nullable
        public static <K,​V> @Nullable java.util.Map<K,​@NotNull V> newConcurrentHashMap​(@Nullable
                                                                                                   @Nullable java.util.Map<K,​@NotNull V> map)
        Creates a new ConcurrentHashMap as a shallow copy of map given by parameter.
        Type Parameters:
        K - the type of map keys
        V - the type of map values
        Parameters:
        map - the map to copy
        Returns:
        the shallow copy of map
      • newHashMap

        @Nullable
        public static <K,​V> @Nullable java.util.Map<K,​@NotNull V> newHashMap​(@Nullable
                                                                                         @Nullable java.util.Map<K,​@NotNull V> map)
        Creates a new HashMap as a shallow copy of map given by parameter.
        Type Parameters:
        K - the type of map keys
        V - the type of map values
        Parameters:
        map - the map to copy
        Returns:
        a new HashMap or null if parameter is null
      • newArrayList

        @Nullable
        public static <T> @Nullable java.util.List<T> newArrayList​(@Nullable
                                                                   @Nullable java.util.List<T> list)
        Creates a new ArrayList as a shallow copy of list given by parameter.
        Type Parameters:
        T - the type of list entries
        Parameters:
        list - the list to copy
        Returns:
        a new ArrayList or null if parameter is null
      • filterMapEntries

        @NotNull
        public static <K,​V> @NotNull java.util.Map<K,​V> filterMapEntries​(@NotNull
                                                                                     @NotNull java.util.Map<K,​V> map,
                                                                                     @NotNull
                                                                                     @NotNull CollectionUtils.Predicate<java.util.Map.Entry<K,​V>> predicate)
        Returns a new map which entries match a predicate specified by a parameter.
        Type Parameters:
        K - - map entry key type
        V - - map entry value type
        Parameters:
        map - - the map to filter
        predicate - - the predicate
        Returns:
        a new map