T
- The type of objects stored in the map.public abstract class AbstractPersistentMap<T> extends Object implements PersistentMap<T>
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
loader
The class loader to use when looking up classes of objects being loaded.
|
protected Class<T> |
typeAware
The class type this map is projecting onto the persistence store.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractPersistentMap(String uniqueId,
String directoryName,
Class<T> typeAware)
Create a new map.
|
protected |
AbstractPersistentMap(String uniqueId,
String directoryName,
Class<T> typeAware,
ClassLoader loader)
Create a new map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all of the key/value associations from this map.
|
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
|
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
|
Set<Map.Entry<String,T>> |
entrySet()
Returns a set of all entries (that is, key/value pairs) stored in this
map.
|
T |
get(Object key)
Returns the value to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
protected abstract String |
getCacheId(String uniqueId)
Get the cache ID for this map.
|
protected T |
getPersistentObject(String objectId)
Look up the persistent object with the given ID.
|
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
Set<String> |
keySet()
Returns the set of all keys currently in use in this map--that is, all
keys that are mapped to values.
|
T |
put(String key,
T value)
Stores a given object in the map by associating it with the given key.
|
void |
putAll(Map<? extends String,? extends T> externalMap)
Copies all of the mappings from the specified map into this map.
|
T |
remove(Object key)
Remove an object from this map by specifying its key.
|
protected void |
removePersistentObject(String objectId)
Remove a persistent object from the store.
|
protected <ObjectType> |
setPersistentObject(String objectId,
ObjectType object)
Set/store the persistent object for a given ID.
|
int |
size()
Returns the number of key-value mappings in this map.
|
Collection<T> |
values()
Returns a collection representing all of the values stored in this map.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
protected Class<T> typeAware
protected ClassLoader loader
protected AbstractPersistentMap(String uniqueId, String directoryName, Class<T> typeAware)
directoryName
- The directory name to use to back this map.typeAware
- The type of objects stored in this map.protected AbstractPersistentMap(String uniqueId, String directoryName, Class<T> typeAware, ClassLoader loader)
directoryName
- The directory name to use to back this map.typeAware
- The type of objects stored in this map.loader
- The class loader to use when looking up classes of
loaded objects.protected abstract String getCacheId(String uniqueId)
public T remove(Object key)
PersistentMap
remove
in interface Map<String,T>
remove
in interface PersistentMap<T>
key
- The key associated with the value to remove. The key must be a
non-null, non-empty string.public T put(String key, T value)
PersistentMap
put
in interface Map<String,T>
put
in interface PersistentMap<T>
key
- The key with which the specified value is to be associated,
which must be a non-null, non-empty string.value
- The object to be associated with the key in the map.public void putAll(Map<? extends String,? extends T> externalMap)
PersistentMap
put(k, v)
on this map once for each mapping
from key k
to value v
in the other map. The
behavior of this operation is undefined if the other map is modified
while the operation is in progress.public T get(Object key)
PersistentMap
T
, then null will be returned. Use
containsKey
to determine if a mapping
exists.get
in interface Map<String,T>
get
in interface PersistentMap<T>
key
- The key whose associated value is to be returned. This key
must be a non-null, non-empty string.public boolean containsKey(Object key)
PersistentMap
containsKey
in interface Map<String,T>
containsKey
in interface PersistentMap<T>
key
- The key whose presence in this map is to be tested, which must
be a non-null, non-empty string.public int size()
PersistentMap
public boolean isEmpty()
PersistentMap
true
if this map contains no key-value mappings.public boolean containsValue(Object value)
PersistentMap
containsValue
in interface Map<String,T>
containsValue
in interface PersistentMap<T>
value
- The value whose presence in the map is being tested.public void clear()
PersistentMap
public Set<String> keySet()
PersistentMap
put()
or remove()
on the map while looping over
the set of keys).public Collection<T> values()
PersistentMap
public Set<Map.Entry<String,T>> entrySet()
PersistentMap
Entry
object represents a key together with its
value, and provides getKey()
and getValue()
methods to access them.protected T getPersistentObject(String objectId)
objectId
- The object ID to look up.protected <ObjectType> void setPersistentObject(String objectId, ObjectType object)
ObjectType
- The type of object to store.objectId
- The ID to associate the object with.object
- The object to store.protected void removePersistentObject(String objectId)
objectId
- The ID of the object to remove.