org.domdrides.repository
Interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>

All Known Subinterfaces:
PageableRepository<EntityType,IdType>

public interface Repository<EntityType extends Entity<IdType>,IdType extends Serializable>

A repository represents a collection of a specific type of objects. Typically, the implementation of a repository involves a database or an ORM mapping tool, but simple Sets can be used also for testing purposes.

Since:
1.0
Author:
James Carman

Method Summary
 EntityType add(EntityType entity)
          Adds the entity to this repository.
 boolean contains(EntityType entity)
          Returns whether or not the entity is contained within the repository.
 Set<EntityType> getAll()
          Returns all entities in this repository as a set.
 EntityType getById(IdType id)
          Returns the entity with the given id.
 void remove(EntityType entity)
          Removes the entity from this repository.
 int size()
          Returns the size of the repository.
 EntityType update(EntityType entity)
          Updates an entity within this repository.
 

Method Detail

add

EntityType add(EntityType entity)
Adds the entity to this repository.

Parameters:
entity - the entity
Returns:
the entity (useful if adding entity to repository changes the entity, e.g. creates oid)

contains

boolean contains(EntityType entity)
Returns whether or not the entity is contained within the repository.

Parameters:
entity - the entity
Returns:
whether or not the entity is contained within the repository

getAll

Set<EntityType> getAll()
Returns all entities in this repository as a set.

Returns:
all entities in this repository as a set

getById

EntityType getById(IdType id)
Returns the entity with the given id.

Parameters:
id - the id
Returns:
the entity with the given id

remove

void remove(EntityType entity)
Removes the entity from this repository.

Parameters:
entity - the entity

update

EntityType update(EntityType entity)
Updates an entity within this repository.

Parameters:
entity - the entity
Returns:
the entity (useful if adding entity to repository changes the entity, e.g. creates oid)

size

int size()
Returns the size of the repository.

Returns:
the size of the repository


Copyright © 2013. All Rights Reserved.