public class InMemoryDao<T extends StrolchRootElement> extends Object implements StrolchDao<T>
| Constructor and Description |
|---|
InMemoryDao(boolean versioningEnabled) |
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
Causes the DAO to flush any actions which have not yet been sent to the underlying persistence layer
|
boolean |
hasElement(String type,
String id)
Returns true if an element exists with the given type and id in the underlying persistence layer
|
List<T> |
queryAll()
Queries and returns all elements regardless of type
|
List<T> |
queryAll(String type)
Queries and returns all elements of the given type
|
T |
queryBy(String type,
String id)
Queries the latest version of the element with the given type and ID
|
T |
queryBy(String type,
String id,
int version)
Queries a specific version of the element with the given type and ID.
|
Set<String> |
queryKeySet()
Queries the set of IDs for all elements, regardless of types from the underlying persistence layer.
|
Set<String> |
queryKeySet(String type)
Queries the set of IDs for the elements with the given type
|
long |
querySize()
Returns the number of elements in the underlying persistence layer, regardless of type
|
long |
querySize(String type)
Returns the number of elements in the underlying persistence layer for the given type
|
Set<String> |
queryTypes()
Queries the current list of types from the underlying persistence layer
|
List<T> |
queryVersionsFor(String type,
String id)
Queries and returns all the versions of the element with the given type and ID
|
long |
queryVersionsSizeFor(String type,
String id)
Queries and returns the number of versions for the element with the given type and ID
|
void |
remove(T element)
Removes the given element from the underlying persistence layer
|
long |
removeAll()
Removes all elements regardless of type from the underlying persistence layer
|
void |
removeAll(List<T> elements)
Removes the given elements from the underlying persistence layer
|
long |
removeAllBy(String type)
Removes all elements of the given type from the underlying persistence layer
|
void |
removeVersion(T element)
Removes the given version of the given element from the underlying persistence layer.
|
void |
save(T element)
Persists the given element.
|
void |
saveAll(List<T> elements)
Persists the given list of elements.
|
void |
update(T element)
Updates the given element.
|
void |
updateAll(List<T> elements)
Updates the given list of elements.
|
public boolean hasElement(String type, String id)
StrolchDaohasElement in interface StrolchDao<T extends StrolchRootElement>type - the type of elementsid - the id of the element to returnpublic long querySize()
StrolchDaoquerySize in interface StrolchDao<T extends StrolchRootElement>public long querySize(String type)
StrolchDaoquerySize in interface StrolchDao<T extends StrolchRootElement>public Set<String> queryKeySet()
StrolchDaoqueryKeySet in interface StrolchDao<T extends StrolchRootElement>public Set<String> queryKeySet(String type)
StrolchDaoqueryKeySet in interface StrolchDao<T extends StrolchRootElement>public Set<String> queryTypes()
StrolchDaoqueryTypes in interface StrolchDao<T extends StrolchRootElement>public T queryBy(String type, String id)
StrolchDaoqueryBy in interface StrolchDao<T extends StrolchRootElement>type - the type of the element to be queriedid - the id of the element to be queriedpublic T queryBy(String type, String id, int version)
StrolchDaoQueries a specific version of the element with the given type and ID.
Note: If you want to query the latest version, then use the method with out the version parameter
queryBy in interface StrolchDao<T extends StrolchRootElement>type - the type of the element to be queriedid - the id of the element to be queriedversion - the version of the element to be returnedpublic List<T> queryVersionsFor(String type, String id)
StrolchDaoqueryVersionsFor in interface StrolchDao<T extends StrolchRootElement>type - the type of the element to be queriedid - the id of the element to be queriedpublic long queryVersionsSizeFor(String type, String id)
StrolchDaoqueryVersionsSizeFor in interface StrolchDao<T extends StrolchRootElement>type - the type of the element to be queriedid - the id of the element to be queriedpublic List<T> queryAll()
StrolchDaoqueryAll in interface StrolchDao<T extends StrolchRootElement>public List<T> queryAll(String type)
StrolchDaoqueryAll in interface StrolchDao<T extends StrolchRootElement>type - the type of element to returnpublic void save(T element)
StrolchDaosave in interface StrolchDao<T extends StrolchRootElement>element - the element to be persistedpublic void saveAll(List<T> elements)
StrolchDaosaveAll in interface StrolchDao<T extends StrolchRootElement>elements - the list of elements to be persistedpublic void update(T element)
StrolchDaoupdate in interface StrolchDao<T extends StrolchRootElement>element - the element to be updatedpublic void updateAll(List<T> elements)
StrolchDaoupdateAll in interface StrolchDao<T extends StrolchRootElement>elements - the elements to be updatedpublic void remove(T element)
StrolchDaoRemoves the given element from the underlying persistence layer
Note: This method deletes the given object including its versions! Do not call this method if you want to use versioning!
remove in interface StrolchDao<T extends StrolchRootElement>element - the element to be removedpublic void removeAll(List<T> elements)
StrolchDaoRemoves the given elements from the underlying persistence layer
Note: This method deletes the given objects including their versions! Do not call this method if you want to use versioning!
removeAll in interface StrolchDao<T extends StrolchRootElement>elements - the elements to be removedpublic long removeAll()
StrolchDaoRemoves all elements regardless of type from the underlying persistence layer
Note: This method does not support versioning. This method completely removes all objects regardless of type and their versions!
removeAll in interface StrolchDao<T extends StrolchRootElement>public long removeAllBy(String type)
StrolchDaoRemoves all elements of the given type from the underlying persistence layer
Note: This method does not support versioning. This method completely removes all objects of the given type and their versions!
removeAllBy in interface StrolchDao<T extends StrolchRootElement>type - the type of element to removepublic void removeVersion(T element) throws StrolchPersistenceException
StrolchDao
Removes the given version of the given element from the underlying persistence layer. The version must be the
latest version and thus always deletes the newest version. To delete multiple versions call this method multiple
times. To remove it completely, call the StrolchDao.remove(StrolchRootElement) method.
Note: This element given must be the current latest version!
removeVersion in interface StrolchDao<T extends StrolchRootElement>element - the latest version of the element to be removedStrolchPersistenceException - if the element/version does not existpublic void flush()
StrolchDaoflush in interface StrolchDao<T extends StrolchRootElement>Copyright © 2011–2016 Strolch. All rights reserved.