Package com.identity4j.util
Class MultiMap
- java.lang.Object
-
- com.identity4j.util.MultiMap
-
- All Implemented Interfaces:
Serializable,Map<String,String[]>
public class MultiMap extends Object implements Serializable, Map<String,String[]>
Object that acts like a Map that can have multiple string values.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,String[]>>entrySet()booleanequals(Object obj)static MultiMapfromMap(Map<String,String[]> map)static MultiMapfromMapSingle(Map<String,String> values)String[]get(Object key)BooleangetBoolean(String key)Get the boolean value of an entry given its key.BooleangetBooleanOrDefault(String key, boolean defaultValue)Get the boolean value of an entry given its key or a default value if no such entry exists.BooleangetBooleanOrFail(String key)Get the boolean value of an entry given its key or fail with an exception if it does not.BooleangetBooleanOrNull(String key)Get the boolean value of an entry given its key ornullif no such entry exists.IntegergetInteger(String key)Get the integer value of an entry given its key.IntegergetIntegerOrDefault(String key, Integer defaultValue)Get the integer value of an entry given its key or a default value if no such entry exists..IntegergetIntegerOrFail(String key)Get the boolean value of an entry given its key or fail with an exception if it does not.IntegergetIntegerOrNull(String key)Get the integer value of an entry given its key ornullif no such entry exists.Iterable<String>getKeyIterator()Get an iterator of all keys.Map<String,String>getMap(String key)Get thejava.util.Mapvalue of an entry given its key.Map<String,String>getMapOrDefault(String key, Map<String,String> defaultValue)Get thejava.util.Mapvalue of an entry given its key or a default value if no such entry exists.Map<String,String>getMapOrFail(String key)Get thejava.util.Mapvalue of an entry given its key or fail with an exception if it does not.Map<String,String>getMapOrNull(String key)Get thejava.util.Mapvalue of an entry given its key ornullif no such entry exists.StringgetString(String key)Get the string value of an entry given its key.String[]getStringArray(String key)Get the string array value of an entry given its key.String[]getStringArrayOrDefault(String key, String... defaultValues)Get the string array value of an entry given its key or default values if no such entry exists.String[]getStringArrayOrFail(String key)Get the string array value of an entry given its key or fail with an exception if it does not.String[]getStringArrayOrNull(String key)Get the string array value of an entry given its key ornullif no such entry exists.StringgetStringOrDefault(String key, String defaultValue)Get the string value of an entry given its key or a default value if no such entry exists..StringgetStringOrFail(String key)Get the string value of an entry given its key or fail with an exception if it does not.StringgetStringOrNull(String key)Get the string value of an entry given its key ornullif no such entry exists.inthashCode()booleanisEmpty()Set<String>keySet()voidmerge(MultiMap source)String[]put(String key, String[] value)voidputAll(Map<? extends String,? extends String[]> map)String[]remove(Object key)String[]set(String key, String... values)Set a value.String[]set(String key, Collection<String> values)Set a value.voidsetAll(Map<String,String[]> values)Sets supplied values.String[]setMore(String key, String... values)Adds the supplied values to any values currently set under this key.intsize()Map<String,String[]>toMap()static Map<String,String>toMap(Map<String,String[]> map)static MultiMaptoMultiMap(Map<String,String> originalMap)Create a newMultiMapgiven a string array map.static MultiMaptoMultiMap(Properties originalMap)Create a newMultiMapgiven properties.StringtoString()Collection<String[]>values()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
setMore
public String[] setMore(String key, String... values)
Adds the supplied values to any values currently set under this key. Anullvalue will be returned if no such value exists.- Parameters:
key- keyvalues- values- Returns:
- old value
-
set
public String[] set(String key, String... values)
Set a value. Anullvalue will be returned if no such value exists.- Parameters:
key- keyvalues- values- Returns:
- old value
-
set
public String[] set(String key, Collection<String> values)
Set a value. Anullvalue will be returned if no such value exists.- Parameters:
key- keyvalues- values- Returns:
- old value
-
getString
public final String getString(String key)
Get the string value of an entry given its key. An empty string will be returned if no such entry exists.- Parameters:
key- entry key- Returns:
- string entry value
-
getStringOrDefault
public final String getStringOrDefault(String key, String defaultValue)
Get the string value of an entry given its key or a default value if no such entry exists..- Parameters:
key- entry keydefaultValue- default value- Returns:
- string entry value
-
getStringOrNull
public final String getStringOrNull(String key)
Get the string value of an entry given its key ornullif no such entry exists.- Parameters:
key- entry key- Returns:
- string entry value
-
getStringOrFail
public final String getStringOrFail(String key)
Get the string value of an entry given its key or fail with an exception if it does not.- Parameters:
key- key- Returns:
- string value
- Throws:
MultiMapException- if no such entry exists
-
getStringArray
public final String[] getStringArray(String key)
Get the string array value of an entry given its key. An empty array will be returned if no such entry exists.- Parameters:
key- entry key- Returns:
- string array entry values
-
getStringArrayOrDefault
public final String[] getStringArrayOrDefault(String key, String... defaultValues)
Get the string array value of an entry given its key or default values if no such entry exists.- Parameters:
key- entry keydefaultValues- default values- Returns:
- string array entry values
-
getStringArrayOrNull
public final String[] getStringArrayOrNull(String key)
Get the string array value of an entry given its key ornullif no such entry exists.- Parameters:
key- entry key- Returns:
- string array entry value
-
getStringArrayOrFail
public final String[] getStringArrayOrFail(String key)
Get the string array value of an entry given its key or fail with an exception if it does not.- Parameters:
key- entry key- Returns:
- string array entry value
- Throws:
MultiMapException- if no such entry exists
-
getBoolean
public final Boolean getBoolean(String key)
Get the boolean value of an entry given its key.Boolean.FALSEwill be returned if no such entry exists.- Parameters:
key- entry key- Returns:
- boolean entry value
-
getBooleanOrDefault
public final Boolean getBooleanOrDefault(String key, boolean defaultValue)
Get the boolean value of an entry given its key or a default value if no such entry exists.- Parameters:
key- entry keydefaultValue- default value- Returns:
- boolean entry value
-
getBooleanOrNull
public final Boolean getBooleanOrNull(String key)
Get the boolean value of an entry given its key ornullif no such entry exists.- Parameters:
key- entry key- Returns:
- boolean entry value
-
getBooleanOrFail
public final Boolean getBooleanOrFail(String key)
Get the boolean value of an entry given its key or fail with an exception if it does not.- Parameters:
key- key- Returns:
- boolean entry value
- Throws:
MultiMapException- if no such entry exists
-
getInteger
public final Integer getInteger(String key)
Get the integer value of an entry given its key.-1will be returned if no such entry exists.- Parameters:
key- entry key- Returns:
- integer entry value
-
getIntegerOrDefault
public final Integer getIntegerOrDefault(String key, Integer defaultValue)
Get the integer value of an entry given its key or a default value if no such entry exists..- Parameters:
key- entry keydefaultValue- default value- Returns:
- integer entry value
-
getIntegerOrNull
public final Integer getIntegerOrNull(String key)
Get the integer value of an entry given its key ornullif no such entry exists.- Parameters:
key- entry key- Returns:
- integer entry value
-
getIntegerOrFail
public final Integer getIntegerOrFail(String key)
Get the boolean value of an entry given its key or fail with an exception if it does not.- Parameters:
key- key- Returns:
- boolean entry value
- Throws:
MultiMapException- if no such entry exists
-
getMap
public final Map<String,String> getMap(String key)
Get thejava.util.Mapvalue of an entry given its key.Collections.emptyMap()will be returned if no such entry exists.- Parameters:
key- entry key- Returns:
- Map entry value
-
getMapOrDefault
public final Map<String,String> getMapOrDefault(String key, Map<String,String> defaultValue)
Get thejava.util.Mapvalue of an entry given its key or a default value if no such entry exists.- Parameters:
key- entry keydefaultValue- default value- Returns:
- Map entry value
-
getMapOrNull
public final Map<String,String> getMapOrNull(String key)
Get thejava.util.Mapvalue of an entry given its key ornullif no such entry exists.- Parameters:
key- entry key- Returns:
- Map entry value
-
getMapOrFail
public final Map<String,String> getMapOrFail(String key)
Get thejava.util.Mapvalue of an entry given its key or fail with an exception if it does not.- Parameters:
key- key- Returns:
- Map entry value
- Throws:
MultiMapException- if no such entry exists
-
getKeyIterator
public final Iterable<String> getKeyIterator()
Get an iterator of all keys.- Returns:
- key iterator
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
toMultiMap
public static MultiMap toMultiMap(Properties originalMap)
Create a newMultiMapgiven properties.- Parameters:
originalMap- string array map- Returns:
- map
-
toMultiMap
public static MultiMap toMultiMap(Map<String,String> originalMap)
Create a newMultiMapgiven a string array map.- Parameters:
originalMap- string array map- Returns:
- map
-
merge
public void merge(MultiMap source)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,String[]>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,String[]>
-
-