net.sourceforge.domian.repository
Class InMemoryRepository<T extends Entity>
java.lang.Object
net.sourceforge.domian.repository.AbstractRepository<T>
net.sourceforge.domian.repository.AbstractDomianCoreRepository<T>
net.sourceforge.domian.repository.InMemoryRepository<T>
- All Implemented Interfaces:
- Repository<T>, VolatileRepository<T>
public class InMemoryRepository<T extends Entity>
- extends AbstractDomianCoreRepository<T>
- implements VolatileRepository<T>
Volatile repository for concurrent environments.
This repository is suitable for all applications with no need for persistent objects.
This repository is backed by a ConcurrentHashMap
.
Only the Map
keys are used, not the values.
Resource usage | |
Storing | O(1) |
Counting | O(N) |
Finding | O(N) |
Removing | O(N) |
- Since:
- 0.4
- Author:
- Eirik Torske
Field Summary |
protected java.util.concurrent.ConcurrentMap<T,java.lang.Object> |
db
|
protected static java.lang.Object |
DUMMY_ELEMENT
|
Methods inherited from class net.sourceforge.domian.repository.AbstractRepository |
contains, count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, findSingleEntitySpecifiedBy, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, putAll, remove, removeAll, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.domian.repository.Repository |
count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, findSingleEntitySpecifiedBy, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, makePartition, putAll, remove, removeAll, update |
DUMMY_ELEMENT
protected static final java.lang.Object DUMMY_ELEMENT
db
protected java.util.concurrent.ConcurrentMap<T extends Entity,java.lang.Object> db
InMemoryRepository
public InMemoryRepository()
countAllEntities
public java.lang.Long countAllEntities()
- Extra method
Counts all entities in repository in the quickest possible way.
iterateAllEntitiesSpecifiedBy
public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
iterateAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
findAllEntitiesSpecifiedBy
public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
findAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
put
public <V extends T> void put(V entity)
- Specified by:
put
in interface Repository<T extends Entity>
update
public <V extends T> void update(V entity)
- Specified by:
update
in interface Repository<T extends Entity>
removeAllEntitiesSpecifiedBy
public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
- Specified by:
removeAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
removeAllEntitites
public void removeAllEntitites()
- Extra method
Purges all entities in repository withour no further ado.
remove
public <V extends T> java.lang.Boolean remove(V entity)
- Specified by:
remove
in interface Repository<T extends Entity>
Copyright © 2006-2010. All Rights Reserved.