public class MemoryDataStore<K extends Serializable,E> extends Object implements DataStore<K,E>
map by mapping entity keys to entities.| Constructor and Description |
|---|
MemoryDataStore(Class<E> entityType) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete(K key)
Deletes the entity identifiable with the provided key, or does nothing if no such entity exists.
|
Class<E> |
getEntityType() |
boolean |
hasKey(K key)
Determines whether or not an entity with the given key exists in the data store.
|
Collection<K> |
keys() |
E |
retrieve(K key)
Given a key, retrieves the entity associated with that key in the data store.
|
Collection<E> |
retrieveAll() |
boolean |
save(K key,
E entity)
Saves the given entity into the data store under the provided key.
|
void |
truncate()
Does a hard remove of all the entities in the data store
|
public boolean hasKey(K key)
DataStorehasKey in interface DataStore<K extends Serializable,E>key - the keypublic boolean save(K key, E entity)
DataStoreDataStore.hasKey(Serializable) should yield true
and the very same entity (or an equal value entity) can be retrieved by calling DataStore.retrieve(Serializable).save in interface DataStore<K extends Serializable,E>key - the keyentity - the entitypublic boolean delete(K key)
DataStoreDataStore.hasKey(Serializable) should return
false and DataStore.retrieve(Serializable) should return null for the same key.delete in interface DataStore<K extends Serializable,E>key - the key for which the removal should happenpublic E retrieve(K key)
DataStoreretrieve in interface DataStore<K extends Serializable,E>key - the keypublic Collection<K> keys()
keys in interface DataStore<K extends Serializable,E>public Collection<E> retrieveAll()
retrieveAll in interface DataStore<K extends Serializable,E>public Class<E> getEntityType()
getEntityType in interface DataStore<K extends Serializable,E>Copyright © 2014–2016. All rights reserved.