Package org.kiwiproject.collect
Class KiwiMaps
- java.lang.Object
-
- org.kiwiproject.collect.KiwiMaps
-
-
Constructor Summary
Constructors Constructor Description KiwiMaps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
booleanisNotNullOrEmpty(Map<K,V> map)
Checks whether the specified map is neither null nor empty.static <K,V>
booleanisNullOrEmpty(Map<K,V> map)
Checks whether the specified map is null or empty.static <K,V>
booleankeyExistsWithNullValue(Map<K,V> map, K key)
Returnstrue
if and only if (1)map
is not null or empty, (2)map
contains the givenkey
, and (3) the value associated with the given key isnull
.static <K,V>
ConcurrentMap<K,V>newConcurrentHashMap(Object... items)
Creates a mutable,ConcurrentHashMap
instance containing key/value pairs as parsed in pairs from the items argument.static <K,V>
Map<K,V>newHashMap(Object... items)
Creates a mutable,HashMap
instance containing key/value pairs as parsed in pairs from the items argument.static <K,V>
Map<K,V>newLinkedHashMap(Object... items)
Creates a mutable,LinkedHashMap
instance containing key/value pairs as parsed in pairs from the items argument.static <K extends Comparable<? super K>,V>
SortedMap<K,V>newTreeMap(Object... items)
Creates a mutable,TreeMap
instance containing key/value pairs as parsed in pairs from the items argument.
-
-
-
Method Detail
-
isNullOrEmpty
public static <K,V> boolean isNullOrEmpty(Map<K,V> map)
Checks whether the specified map is null or empty.- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
map
- the map- Returns:
true
if map is null or empty;false
otherwise
-
isNotNullOrEmpty
public static <K,V> boolean isNotNullOrEmpty(Map<K,V> map)
Checks whether the specified map is neither null nor empty.- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
map
- the map- Returns:
true
if map is neither null nor empty;false
otherwise
-
newHashMap
public static <K,V> Map<K,V> newHashMap(Object... items)
Creates a mutable,HashMap
instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:key-1, value-1, key-2, value-2, ... , key-N, value-N
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the items containing keys and values, in pairs- Returns:
- a new HashMap with data from items
-
newLinkedHashMap
public static <K,V> Map<K,V> newLinkedHashMap(Object... items)
Creates a mutable,LinkedHashMap
instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:key-1, value-1, key-2, value-2, ... , key-N, value-N
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the items containing keys and values, in pairs- Returns:
- a new LinkedHashMap with data from items
-
newTreeMap
public static <K extends Comparable<? super K>,V> SortedMap<K,V> newTreeMap(Object... items)
Creates a mutable,TreeMap
instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:key-1, value-1, key-2, value-2, ... , key-N, value-N
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the items containing keys and values, in pairs- Returns:
- a new TreeMap with data from items
-
newConcurrentHashMap
public static <K,V> ConcurrentMap<K,V> newConcurrentHashMap(Object... items)
Creates a mutable,ConcurrentHashMap
instance containing key/value pairs as parsed in pairs from the items argument. The items argument contains keys and values in the form:key-1, value-1, key-2, value-2, ... , key-N, value-N
- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
items
- the items containing keys and values, in pairs- Returns:
- a new ConcurrentHashMap with data from items
-
keyExistsWithNullValue
public static <K,V> boolean keyExistsWithNullValue(Map<K,V> map, K key)
Returnstrue
if and only if (1)map
is not null or empty, (2)map
contains the givenkey
, and (3) the value associated with the given key isnull
.- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
map
- the mapkey
- the key check- Returns:
true
if and only if (1)map
is not null or empty, (2)map
contains the givenkey
, and (3) the value associated with the given key isnull
-
-