Package com.linkedin.venice.utils
Class CollectionUtils
java.lang.Object
com.linkedin.venice.utils.CollectionUtils
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasUnmodifiableList(float[] array) convertCharSequenceMapToStringMap(Map<CharSequence, CharSequence> charSequenceMap) static Map<CharSequence,CharSequence> convertStringMapToCharSequenceMap(Map<String, String> stringMap) static Map<CharSequence,CharSequence> getCharSequenceMapFromStringMap(Map<String, String> stringStringMap) static Map<String,CharSequence> getStringKeyCharSequenceValueMapFromStringMap(Map<String, String> stringMap) getStringMapFromCharSequenceMap(Map<CharSequence, CharSequence> charSequenceMap) static booleanstatic booleanstatic <T> booleanlistEquals(List<T> list1, List<T> list2) A manual implementation of list equality.static <K,V> CollectionUtils.MapBuilder<K, V> static <T> List<T>reversed(Collection<T> collection) A reversed copy of the given collectionstatic <T> Set<T>setOf(Collection<T> values) static <T> Set<T>setOf(T value) static <T> Set<T>setOf(T... values) 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.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
listEquals
A manual implementation of list equality. This is (unfortunately) useful with Avro lists since they do not work reliably. There are cases where aList<T>coming out of an Avro record will be implemented as aGenericData.Arrayand other times it will be a javaArrayList. When this happens, the equality check fails...- Returns:
- true if both lists have the same items in the same order
-
asUnmodifiableList
-
reversed
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
-
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
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 singletonCollections.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
-
isEmpty
-
isEmpty
-
mapBuilder
-
setOf
-
setOf
-
setOf
-