|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.domian.repository.AbstractRepository<T> net.sourceforge.domian.repository.AbstractDomianCoreRepository<T> net.sourceforge.domian.repository.HashSetRepository<T>
public class HashSetRepository<T extends Entity>
Volatile repository for non-concurrent environments.
This repository is suitable for standalone single-threaded applications with no need for persistent objects, e.g. testing. Another usage example is local selection/projection of a set of objects using a specification. To be able to use the specification, just create aHashSetRepository
, populate it with the objects to select from
using the putAll(Collection)
method, and then invoke the findAllEntitiesSpecifiedBy(Specification)
method.
Indeed, there is a convenience constructor made for this particular use case.
This repository is backed by an unsynchronized HashSet
.
(Another way of putting it is that this class is just a Repository
-wrapped Collection
,
or a Specification
-activated Collection
...)
Resource usage | |
---|---|
Storing | O(1) |
Counting | O(N) |
Finding | O(N) |
Removing | O(N) |
Nested Class Summary | |
---|---|
protected static class |
HashSetRepository.HashSetRepositoryIterator<V extends Entity,T extends Entity>
Inner iterator class for HashSetRepository . |
Field Summary | |
---|---|
protected java.util.Set<T> |
db
|
Fields inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
DEFAULT_DOMIAN_ROOT_DIR_NAME, DEFAULT_DOMIAN_ROOT_PATH, log, synchronizer |
Fields inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
supportsRecursiveIndexing, usesNativePartitioningSupport |
Constructor Summary | |
---|---|
HashSetRepository()
|
|
HashSetRepository(java.util.Collection<T> initialEntities)
Convenient constructor for the specifications-based-compact-sorting use case. |
Method Summary | ||
---|---|---|
java.lang.Long |
countAllEntities()
Extra method Counts all entities in repository rather fast. |
|
|
findAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
|
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
|
put(V entity)
Puts the given entity into this repository. |
|
void |
putAll(java.util.Collection<? extends T> collectionOfEntities)
Puts the given entities into this repository. |
|
|
remove(V entity)
Removes the given entity from this repository. |
|
void |
removeAllEntities()
Extra method Purges all entities in repository without no further ado. |
|
|
removeAllEntitiesSpecifiedBy(Specification<V> specification)
Removes all entities approved by the given specification. |
|
|
update(V entity)
Updates an entity. |
Methods inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
createUniqueSpecificationFor, getSynchronizer, makePartition, onMakePartition, setSynchronizer |
Methods inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
contains, count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, findSingleEntitySpecifiedBy, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, 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, remove, removeAll, update |
Field Detail |
---|
protected java.util.Set<T extends Entity> db
Constructor Detail |
---|
public HashSetRepository()
public HashSetRepository(java.util.Collection<T> initialEntities)
Method Detail |
---|
public java.lang.Long countAllEntities()
public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
iterateAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
findAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> void put(V entity)
Repository
put
in interface Repository<T extends Entity>
entity
- the entity to be storedpublic void putAll(java.util.Collection<? extends T> collectionOfEntities)
Repository
putAll
in interface Repository<T extends Entity>
putAll
in class AbstractRepository<T extends Entity>
collectionOfEntities
- the entities to be storedpublic <V extends T> void update(V entity)
Repository
PersistenceDefinition.FILE
, and possibly PersistenceDefinition.DELEGATED
...
For all other persistence definitions, this method is redundant/not applicable.
Anyway, by applying this method in a consistent manner, an eventual repository migration will not need any code changes.
update
in interface Repository<T extends Entity>
public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
removeAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public void removeAllEntities()
public <V extends T> java.lang.Boolean remove(V entity)
Repository
remove
in interface Repository<T extends Entity>
entity
- the entity to be removed
true
if the entity is found and removed, otherwise false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |