net.sourceforge.domian.repository
Interface Repository<T extends Entity>

All Known Subinterfaces:
BinaryFormatRepository<T>, FakeRepository<T>, HumanReadableFormatRepository<T>, PartitionRepository<T>, PersistentRepository<T>, TextualFormatRepository<T>, VolatileRepository<T>
All Known Implementing Classes:
AbstractDomianCoreRepository, AbstractRepository, HashSetRepository, HibernateRepository, InMemoryAndXStreamXmlFileRepository, InMemoryRepository, NotImplementedRepository, NullRepository, PartitionRepositoryInvocationHandler, PartitionRepositoryReuseInvocationHandler, UnsupportedRepository, XStreamXmlFilePerEntityRepository

public interface Repository<T extends Entity>

Interface defining a repository for storing and retrieving Entity objects.

Since:
0.4
Author:
Eirik Torske

Method Summary
 java.lang.Long count(Specification<? extends T> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
 java.lang.Long countAll(Specification<? extends T> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
 java.lang.Long countAllEntitiesSpecifiedBy(Specification<? extends T> specification)
          Counts the number of entities approved by the given specification.
<V extends T>
java.util.Collection<V>
find(Specification<V> specification)
          Alias of findAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Collection<V>
findAll(Specification<V> specification)
          Alias of findAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Collection<V>
findAllEntitiesSpecifiedBy(Specification<V> specification)
          Finds and returns all entities approved by the given specification.
<V extends T>
V
findSingle(Specification<V> specification)
          Alias of findSingleEntitySpecifiedBy(Specification).
<V extends T>
V
findSingleEntitySpecifiedBy(Specification<V> specification)
          Finds and returns one single entity approved by the given specification.
 java.lang.Boolean isIndexingEntitiesRecursively()
           
 java.lang.Boolean isPartitioningNatively()
          When true, the repository utilizes some sort of native partitioning mechanism, e.g.
<V extends T>
java.util.Iterator<V>
iterate(Specification<V> specification)
          Alias of iterateAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Iterator<V>
iterateAll(Specification<V> specification)
          Alias of iterateAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Iterator<V>
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
          Finds and returns all entities approved by the given specification.
 PartitionRepository<T> makePartition()
          Promotes this repository to a PartitionRepository.
<V extends T>
void
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.
<V extends T>
java.lang.Long
remove(Specification<V> specification)
          Alias of removeAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Boolean
remove(V entity)
          Removes the given entity from this repository.
<V extends T>
java.lang.Long
removeAll(Specification<V> specification)
          Alias of removeAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Long
removeAllEntitiesSpecifiedBy(Specification<V> specification)
          Removes all entities approved by the given specification.
<V extends T>
void
update(V entity)
          Updates an entity.
<V extends T>
void
update(V entity, Specification<?> deltaSpecification)
          Updates an entity.
 

Method Detail

countAllEntitiesSpecifiedBy

java.lang.Long countAllEntitiesSpecifiedBy(Specification<? extends T> specification)
Counts the number of entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the number of entities approved by the specification argument
Throws:
java.lang.IllegalArgumentException - if parameter is null

countAll

java.lang.Long countAll(Specification<? extends T> specification)
Alias of countAllEntitiesSpecifiedBy(Specification).


count

java.lang.Long count(Specification<? extends T> specification)
Alias of countAllEntitiesSpecifiedBy(Specification).


iterateAllEntitiesSpecifiedBy

<V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. An iterator is returned for lazy retrieval of the entities.

Parameters:
specification - the entity specification
Returns:
an iterator with all entities approved by the specification argument
Throws:
java.lang.IllegalArgumentException - if parameter is null

iterateAll

<V extends T> java.util.Iterator<V> iterateAll(Specification<V> specification)
Alias of iterateAllEntitiesSpecifiedBy(Specification).


iterate

<V extends T> java.util.Iterator<V> iterate(Specification<V> specification)
Alias of iterateAllEntitiesSpecifiedBy(Specification).


findAllEntitiesSpecifiedBy

<V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
a collection of all entities approved by the specification argument, or an empty set if no entities are found and approved
Throws:
java.lang.IllegalArgumentException - if parameter is null

findAll

<V extends T> java.util.Collection<V> findAll(Specification<V> specification)
Alias of findAllEntitiesSpecifiedBy(Specification).


find

<V extends T> java.util.Collection<V> find(Specification<V> specification)
Alias of findAllEntitiesSpecifiedBy(Specification).


findSingleEntitySpecifiedBy

<V extends T> V findSingleEntitySpecifiedBy(Specification<V> specification)
Finds and returns one single entity approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the sole entity specified by the specification argument, or null if no entity is found
Throws:
java.lang.IllegalArgumentException - if parameter is null
java.lang.IllegalArgumentException - if more then one entity is specified by the given specification

findSingle

<V extends T> V findSingle(Specification<V> specification)
Alias of findSingleEntitySpecifiedBy(Specification).


put

<V extends T> void put(V entity)
Puts the given entity into this repository.

Parameters:
entity - the entity to be stored

putAll

void putAll(java.util.Collection<? extends T> collectionOfEntities)
Puts the given entities into this repository.

Parameters:
collectionOfEntities - the entities to be stored
Throws:
java.lang.IllegalArgumentException - if parameter is null

update

<V extends T> void update(V entity)
Updates an entity. When an entity is (re)-retrieved, all state changes will be visible, no matter what kinds of repository implementations being involved. Do notice that for all memory-based repositories (and possibly some delegated ones), entity updates are of course immediately visible.

(Only applicable for persistent repositories doing explicit data writes, like 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

<V extends T> void update(V entity,
                          Specification<?> deltaSpecification)
Updates an entity. When an entity is (re)-retrieved, all state changes will be visible, no matter what kinds of repository implementations being involved. Do notice that for all memory-based repositories (and possibly some delegated ones), entity updates are of course immediately visible.

(Only applicable for persistent repositories doing direct data writes, like 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.

Type Parameters:
V - the entity type
Parameters:
entity - the entity
deltaSpecification - for optimistic locking schemes: a specification specifying the differences/added state between this update and the previously retrieved entity version The specification should be a conjuction of field bound equality specifications only, or null if optimistic locking with automatic retries is completely out of scope

removeAllEntitiesSpecifiedBy

<V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Removes all entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the number of removed entities
Throws:
java.lang.IllegalArgumentException - if parameter is null

removeAll

<V extends T> java.lang.Long removeAll(Specification<V> specification)
Alias of removeAllEntitiesSpecifiedBy(Specification).


remove

<V extends T> java.lang.Long remove(Specification<V> specification)
Alias of removeAllEntitiesSpecifiedBy(Specification).


remove

<V extends T> java.lang.Boolean remove(V entity)
Removes the given entity from this repository.

Parameters:
entity - the entity to be removed
Returns:
true if the entity is found and removed, otherwise false

makePartition

PartitionRepository<T> makePartition()
Promotes this repository to a PartitionRepository.

Returns:
a partitioned version of this repository

isPartitioningNatively

java.lang.Boolean isPartitioningNatively()
When true, the repository utilizes some sort of native partitioning mechanism, e.g. RDBMS indices. If true, partition repositories may be reusing the same repository instance.

Returns:
true if repository utilizes some sort of native partitioning mechanism, e.g. RDBMS indices.

isIndexingEntitiesRecursively

java.lang.Boolean isIndexingEntitiesRecursively()
Returns:
true if member entities are stored recursively, and made searchable - false if only aggregate root is stored.


Copyright © 2006-2010. All Rights Reserved.