Class CollectionUtils

java.lang.Object
com.linkedin.venice.utils.CollectionUtils

public class CollectionUtils extends Object
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • listEquals

      public static <T> boolean listEquals(List<T> list1, 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<T> 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 List<Float> asUnmodifiableList(float[] array)
    • reversed

      public static <T> List<T> reversed(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 Map<CharSequence,CharSequence> getCharSequenceMapFromStringMap(Map<String,String> stringStringMap)
    • getStringKeyCharSequenceValueMapFromStringMap

      public static Map<String,CharSequence> getStringKeyCharSequenceValueMapFromStringMap(Map<String,String> stringMap)
    • getStringMapFromCharSequenceMap

      public static Map<String,String> getStringMapFromCharSequenceMap(Map<CharSequence,CharSequence> charSequenceMap)
    • convertStringMapToCharSequenceMap

      public static Map<CharSequence,CharSequence> convertStringMapToCharSequenceMap(Map<String,String> stringMap)
    • convertCharSequenceMapToStringMap

      public static Map<String,String> convertCharSequenceMapToStringMap(Map<CharSequence,CharSequence> charSequenceMap)
    • substituteEmptyMap

      public static <K, V> Map<K,V> substituteEmptyMap(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
    • mapBuilder

      public static <K, V> CollectionUtils.MapBuilder<K,V> mapBuilder()
    • setOf

      public static <T> Set<T> setOf(T value)
    • setOf

      @SafeVarargs public static <T> Set<T> setOf(T... values)
    • setOf

      public static <T> Set<T> setOf(Collection<T> values)