it.amattioli.dominate.repositories
Class CompositeRepositoryFactory

Show UML class diagram
java.lang.Object
  extended by it.amattioli.dominate.repositories.CompositeRepositoryFactory
All Implemented Interfaces:
RepositoryFactory

public class CompositeRepositoryFactory
extends Object
implements RepositoryFactory

A repository factory that delegates the creation of repositories to other factories. Users can register delegate factories with addFactory(RepositoryFactory) method. Then getRepository(Class) will try on every registered factory until it finds one that creates the resulting repository. The factories will be called in the same order in which they were registered.

Author:
andrea

Constructor Summary
CompositeRepositoryFactory()
           
 
Method Summary
 void addFactory(RepositoryFactory factory)
          Register a new factory
<I extends Serializable,T extends Entity<I>>
Repository<I,T>
getRepository(Class<T> c)
          Create a repository for objects of the given class.
<I extends Serializable,T extends Entity<I>>
Repository<I,T>
getRepository(Collection<T> c)
          Create an adapter that present the given collection as a repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeRepositoryFactory

public CompositeRepositoryFactory()
Method Detail

addFactory

public void addFactory(RepositoryFactory factory)
Register a new factory

Parameters:
factory - the factory to register

getRepository

public <I extends Serializable,T extends Entity<I>> Repository<I,T> getRepository(Class<T> c)
Description copied from interface: RepositoryFactory
Create a repository for objects of the given class.

Specified by:
getRepository in interface RepositoryFactory
Type Parameters:
I - The class of the id of the objects contained in the constructed repository
T - The class of the objects contained in the constructed repository
Parameters:
c - The class object of the objects contained in the constructed repository
Returns:
a new repository for objects of class c or null if this repositoryFactory cannot create a repository for the given class

getRepository

public <I extends Serializable,T extends Entity<I>> Repository<I,T> getRepository(Collection<T> c)
Description copied from interface: RepositoryFactory
Create an adapter that present the given collection as a repository.

Specified by:
getRepository in interface RepositoryFactory
Type Parameters:
I - The class of the id of the objects contained in the constructed repository
T - The class of the objects contained in the constructed repository
Parameters:
c - The collection that will be adapted as a repository
Returns:
the newly created repository


Copyright © 2011. All Rights Reserved.