Class CollectionUtils


  • public class CollectionUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      CollectionUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<java.lang.Float> asUnmodifiableList​(float[] array)  
      static java.util.Map<java.lang.String,​java.lang.String> convertCharSequenceMapToStringMap​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> charSequenceMap)  
      static java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> convertStringMapToCharSequenceMap​(java.util.Map<java.lang.String,​java.lang.String> stringMap)  
      static java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> getCharSequenceMapFromStringMap​(java.util.Map<java.lang.String,​java.lang.String> stringStringMap)  
      static java.util.Map<java.lang.String,​java.lang.CharSequence> getStringKeyCharSequenceValueMapFromStringMap​(java.util.Map<java.lang.String,​java.lang.String> stringMap)  
      static java.util.Map<java.lang.String,​java.lang.String> getStringMapFromCharSequenceMap​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> charSequenceMap)  
      static <T> boolean listEquals​(java.util.List<T> list1, java.util.List<T> list2)
      A manual implementation of list equality.
      static <T> java.util.List<T> reversed​(java.util.Collection<T> collection)
      A reversed copy of the given collection
      static <K,​V>
      java.util.Map<K,​V>
      substituteEmptyMap​(java.util.Map<K,​V> map)
      This function can be useful when we want: - To ensure a map is not null.
      • Methods inherited from class java.lang.Object

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

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • listEquals

        public static <T> boolean listEquals​(java.util.List<T> list1,
                                             java.util.List<T> list2)
        A manual implementation of list equality. This is (unfortunately) useful with Avro lists since they do not work reliably. There are cases where a List coming out of an Avro record will be implemented as a GenericData.Array and other times it will be a java ArrayList. When this happens, the equality check fails...
        Returns:
        true if both lists have the same items in the same order
      • asUnmodifiableList

        public static java.util.List<java.lang.Float> asUnmodifiableList​(float[] array)
      • reversed

        public static <T> java.util.List<T> reversed​(java.util.Collection<T> collection)
        A reversed copy of the given collection
        Type Parameters:
        T - The type of the items in the list
        Parameters:
        collection - The collection to reverse
        Returns:
        The list, reversed
      • getCharSequenceMapFromStringMap

        public static java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> getCharSequenceMapFromStringMap​(java.util.Map<java.lang.String,​java.lang.String> stringStringMap)
      • getStringKeyCharSequenceValueMapFromStringMap

        public static java.util.Map<java.lang.String,​java.lang.CharSequence> getStringKeyCharSequenceValueMapFromStringMap​(java.util.Map<java.lang.String,​java.lang.String> stringMap)
      • getStringMapFromCharSequenceMap

        public static java.util.Map<java.lang.String,​java.lang.String> getStringMapFromCharSequenceMap​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> charSequenceMap)
      • convertStringMapToCharSequenceMap

        public static java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> convertStringMapToCharSequenceMap​(java.util.Map<java.lang.String,​java.lang.String> stringMap)
      • convertCharSequenceMapToStringMap

        public static java.util.Map<java.lang.String,​java.lang.String> convertCharSequenceMapToStringMap​(java.util.Map<java.lang.CharSequence,​java.lang.CharSequence> charSequenceMap)
      • substituteEmptyMap

        public static <K,​V> java.util.Map<K,​V> substituteEmptyMap​(java.util.Map<K,​V> map)
        This function can be useful when we want: - To ensure a map is not null. - To avoid hanging on to many references of empty maps (as opposed to the singleton Collections.EMPTY_MAP).
        Parameters:
        map - to be returned if populated, or substituted if null or empty
        Returns:
        a non-null map with the same content (though not necessarily the same identity) as the input map