public class DefaultValueStore extends Object implements ValueStore
ValueStore
.
Simply uses Map
as underlying storage.
Primitive values will be autoboxed to corresponding wrapper values when they
are stored.
Constructor and Description |
---|
DefaultValueStore() |
Modifier and Type | Method and Description |
---|---|
Object |
get(Object key)
Get the value associated to the key.
|
<T> T |
get(Object key,
Class<T> type)
Get the value associated to the key and cast to the type.
|
<T> T |
getOrDefault(Object key,
T defaultValue)
Get the value associated to the key; otherwise returns specified value.
|
void |
put(Object key,
Object value)
Store a value associating the provided key.
|
void |
putAll(Map<Object,Object> map)
Store all key value pairs from provided map.
|
Object |
remove(Object key)
Remove the value associated to the provided key.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
create
public Object get(Object key)
ValueStore
get
in interface ValueStore
key
- keynull
public <T> T get(Object key, Class<T> type)
ValueStore
get
in interface ValueStore
T
- value typekey
- keytype
- value type to castnull
public <T> T getOrDefault(Object key, T defaultValue)
ValueStore
getOrDefault
in interface ValueStore
T
- value typekey
- keydefaultValue
- default valuepublic void put(Object key, Object value)
ValueStore
put
in interface ValueStore
key
- keyvalue
- valuepublic void putAll(Map<Object,Object> map)
ValueStore
putAll
in interface ValueStore
map
- mappublic Object remove(Object key)
ValueStore
remove
in interface ValueStore
key
- keynull
if key did not existCopyright © 2024. All rights reserved.