Package liquibase.util
Class SmartMap
- java.lang.Object
-
- liquibase.util.SmartMap
-
public class SmartMap extends Object implements Map<String,Object>
Implementation of Map with the added methodsget(String, Class)andget(String, Object)to make the return values type safe and/or auto-converted. Also addsset(String, Object)for easier builder-style code. Returns keys in alphabetical order.
-
-
Constructor Summary
Constructors Constructor Description SmartMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,Object>>entrySet()booleanequals(Object o)Objectget(Object key)<T> Tget(String key, Class<T> type)Return the value for the given key converted to the passed type.<T> Tget(String key, T defaultValue)Return the value for the given key converted to the type of the default value.inthashCode()booleanisEmpty()Set<String>keySet()Objectput(String key, Object value)Like normalMap.put(Object, Object)operation, but if null is passed as "value" it removes the key/value from the map.voidputAll(Map<? extends String,?> m)Objectremove(Object key)SmartMapset(String key, Object value)Works likeput(String, Object)but returns this SmartMap rather than the old value.intsize()Collection<Object>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
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,Object>
-
get
public <T> T get(String key, Class<T> type)
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
public <T> T get(String key, T defaultValue)
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
public Object put(String key, Object value)
Like normalMap.put(Object, Object)operation, but if null is passed as "value" it removes the key/value from the map.
-
set
public SmartMap set(String key, Object value)
Works likeput(String, Object)but returns this SmartMap rather than the old value.
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
-