Package liquibase.util
Class SmartMap
java.lang.Object
liquibase.util.SmartMap
Implementation of Map with the added methods
get(String, Class)
and get(String, Object)
to make the return values type safe and/or auto-converted.
Also adds set(String, Object)
for easier builder-style code.
Returns keys in alphabetical order.-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
<T> T
Return the value for the given key converted to the passed type.<T> T
Return the value for the given key converted to the type of the default value.int
hashCode()
boolean
isEmpty()
keySet()
Like normalMap.put(Object, Object)
operation, but if null is passed as "value" it removes the key/value from the map.void
Works likeput(String, Object)
but returns this SmartMap rather than the old value.int
size()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
SmartMap
public SmartMap()
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
Object>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
Object>
-
get
-
get
Return the value for the given key converted to the passed type. If the value associated with the key is null, null is returned. If the stored value is different than the passed type, a conversion is attempted usingObjectUtil.convert(Object, Class)
. Any conversion is done only on the return value. The stored value is unchanged. -
get
Return the value for the given key converted to the type of the default value. If the value is null, defaultValue is returned. Conversion is done usingget(String, Class)
-
put
Like normalMap.put(Object, Object)
operation, but if null is passed as "value" it removes the key/value from the map. -
set
Works likeput(String, Object)
but returns this SmartMap rather than the old value. -
remove
-
putAll
-
clear
public void clear() -
equals
-
hashCode
public int hashCode() -
keySet
-
values
-
entrySet
-