Package liquibase.util
Class CollectionUtil
- java.lang.Object
-
- liquibase.util.CollectionUtil
-
public class CollectionUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description CollectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>
createIfNull(List<T> currentValue)
Returns passed currentValue if it is not null and creates a new ArrayList if it is null.static <T,E>
Map<T,E>createIfNull(Map<T,E> currentValue)
Returns a new empty map if the passed map is null.static <T> Set<T>
createIfNull(Set<T> currentValue)
Returns a new empty set if the passed set is null.static <T> T[]
createIfNull(T[] arguments)
Returns a new empty array if the passed array is null.static String
findKeyInMapIgnoreCase(String key, Map<String,Object> map)
Find the actual key in a map, by searching the keys in the map and checking them ignoring case.static Map<String,Object>
flatten(Map<String,Object> map)
Converts a set of nested maps (like from yaml/json) into a flat map with dot-separated propertiesstatic <T> List<Map<String,T>>
permutations(Map<String,List<T>> parameterValues)
static <T> Set<Set<T>>
powerSet(Collection<T> originalSet)
-
-
-
Method Detail
-
powerSet
public static <T> Set<Set<T>> powerSet(Collection<T> originalSet)
-
permutations
public static <T> List<Map<String,T>> permutations(Map<String,List<T>> parameterValues)
-
createIfNull
public static <T> List<T> createIfNull(List<T> currentValue)
Returns passed currentValue if it is not null and creates a new ArrayList if it is null.
Example: values = createIfNull(values)
-
createIfNull
public static <T> T[] createIfNull(T[] arguments)
Returns a new empty array if the passed array is null.
-
createIfNull
public static <T> Set<T> createIfNull(Set<T> currentValue)
Returns a new empty set if the passed set is null.
-
createIfNull
public static <T,E> Map<T,E> createIfNull(Map<T,E> currentValue)
Returns a new empty map if the passed map is null.
-
flatten
public static Map<String,Object> flatten(Map<String,Object> map)
Converts a set of nested maps (like from yaml/json) into a flat map with dot-separated properties
-
findKeyInMapIgnoreCase
public static String findKeyInMapIgnoreCase(String key, Map<String,Object> map)
Find the actual key in a map, by searching the keys in the map and checking them ignoring case.- Parameters:
key
- the key to search for, in any casemap
- the map in which to search- Returns:
- the properly cased key, if found, or null if not found
-
-