it.amattioli.dominate.repositories
Class AbstractRepositoryBridge<I extends Serializable,T extends Entity<I>>

Show UML class diagram
java.lang.Object
  extended by it.amattioli.dominate.repositories.AbstractRepositoryBridge<I,T>
Type Parameters:
I -
T -
All Implemented Interfaces:
Repository<I,T>, Cloneable

public abstract class AbstractRepositoryBridge<I extends Serializable,T extends Entity<I>>
extends Object
implements Repository<I,T>

An abstract implementation for a repository bridge.

Author:
andrea

Constructor Summary
protected AbstractRepositoryBridge(Repository<I,T> bridged)
           
 
Method Summary
 void addOrder(String property, boolean reverse)
          Add an order property for the lists retrieved using Repository.list() and Repository.list(Specification).
 void fillCollection(Collection<? super T>... toBeFilled)
           
 void fillCollection(Filter criteria, Collection<? super T>... toBeFilled)
           
 T get(I id)
          Retrieve an entity from this repository using its id.
protected  Repository<I,T> getBridged()
           
 T getByPropertyValue(String propertyName, Object value)
          Retrieves the object contained in this repository that has a specified property equals to a certain value.
<J extends Serializable,E extends Entity<J>>
Repository<J,E>
getDetailRepository(Collection<E> details)
           
 int getFirst()
          Retrieves the index of the first object that will be retrieved by Repository.list() e Repository.list(Filter).
 int getLast()
          Retrieves the index of the last object that will be retrieved by Repository.list() e Repository.list(Specification).
 String getOrderProperty()
          Retrieves the name of the property used for ordering the result of the Repository.list() and Repository.list(Specification) methods.
 boolean isRemoveAllowed()
          Check if this repository supports object removal.
 boolean isReverseOrder()
          Returns true if the order of the result of the Repository.list() and Repository.list(Specification) methods is ascending, false otherwise.
 List<T> list()
          Retrieves all the objects contained in this repository.
 List<T> list(Filter criteria)
          Retrieves the objects contained in this repository that match the specified filter.
 List<T> list(Specification<T> spec)
          Retrieves the objects contained in this repository that satisfied the given specification.
 void put(T object)
          Add a new entity to this repository.
 void refresh(I objectId)
          If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source.
 void refresh(T object)
          If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source.
 void remove(I objectId)
          Removes an object from this repository.
 void remove(T object)
          Removes an object from this repository.
 void removeLastOrder()
          Remove the last added order property.
 void setFirst(int first)
          Set the index of the first object that will be retrieved by Repository.list() and Repository.list(Filter) when value 0 has been set for 'first' in the filter.
 void setLast(int last)
          Set the index of the last object that will be retrieved by Repository.list() e Repository.list(Filter) when value 0 has been set for 'first' in the filter.
 void setOrder(String property, boolean reverse)
          Set the order for the lists retrieved using Repository.list() and Repository.list(Specification).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRepositoryBridge

protected AbstractRepositoryBridge(Repository<I,T> bridged)
Method Detail

getBridged

protected Repository<I,T> getBridged()

fillCollection

public void fillCollection(Collection<? super T>... toBeFilled)
Specified by:
fillCollection in interface Repository<I extends Serializable,T extends Entity<I>>

fillCollection

public void fillCollection(Filter criteria,
                           Collection<? super T>... toBeFilled)
Specified by:
fillCollection in interface Repository<I extends Serializable,T extends Entity<I>>

get

public T get(I id)
Description copied from interface: Repository
Retrieve an entity from this repository using its id.

Specified by:
get in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
id - the id of the entity you want to retrieve.
Returns:
the entity, contained in this repository, whose id is the same as the parameter

getByPropertyValue

public T getByPropertyValue(String propertyName,
                            Object value)
Description copied from interface: Repository
Retrieves the object contained in this repository that has a specified property equals to a certain value.

This method makes sense only if the specified property has distinct values for each entity.

If there is no entity in this repository that has the specified value, null is returned.

if there is more than one entity in this repository that has the specified value, one of them is returned.

Specified by:
getByPropertyValue in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
propertyName - the name of the property
value - the property value
Returns:

getDetailRepository

public <J extends Serializable,E extends Entity<J>> Repository<J,E> getDetailRepository(Collection<E> details)
Specified by:
getDetailRepository in interface Repository<I extends Serializable,T extends Entity<I>>

getFirst

public int getFirst()
Description copied from interface: Repository
Retrieves the index of the first object that will be retrieved by Repository.list() e Repository.list(Filter).

Specified by:
getFirst in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:
the index of the first object that will be retrieved by Repository.list() e Repository.list(Filter)

getLast

public int getLast()
Description copied from interface: Repository
Retrieves the index of the last object that will be retrieved by Repository.list() e Repository.list(Specification). This method will retrieve the same number that has been set using Repository.setLast(int) independently of the repository content size.

Specified by:
getLast in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:
the index of the last object that will be retrieved by Repository.list() and Repository.list(Filter)

getOrderProperty

public String getOrderProperty()
Description copied from interface: Repository
Retrieves the name of the property used for ordering the result of the Repository.list() and Repository.list(Specification) methods.

Specified by:
getOrderProperty in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:
the name of the property used for ordering

isRemoveAllowed

public boolean isRemoveAllowed()
Description copied from interface: Repository
Check if this repository supports object removal.

Specified by:
isRemoveAllowed in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:
true if this repository supports object removal

isReverseOrder

public boolean isReverseOrder()
Description copied from interface: Repository
Returns true if the order of the result of the Repository.list() and Repository.list(Specification) methods is ascending, false otherwise.

Specified by:
isReverseOrder in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:

addOrder

public void addOrder(String property,
                     boolean reverse)
Description copied from interface: Repository
Add an order property for the lists retrieved using Repository.list() and Repository.list(Specification). If a previous order property was set it will remain in place and the new property will be added to the list.

Specified by:
addOrder in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
property - the name of the property that will be used to order the lists
reverse - if this parameter is true the order will be ascendant, otherwise it will be descendant

removeLastOrder

public void removeLastOrder()
Description copied from interface: Repository
Remove the last added order property. If no order was set nothing will happen.

Specified by:
removeLastOrder in interface Repository<I extends Serializable,T extends Entity<I>>

list

public List<T> list()
Description copied from interface: Repository
Retrieves all the objects contained in this repository. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Specified by:
list in interface Repository<I extends Serializable,T extends Entity<I>>
Returns:
all the entities contained in this repository
See Also:
#setFirst(int)}, {@link #setLast(int)}, {@link #setOrder(String, boolean)}

list

public List<T> list(Filter criteria)
Description copied from interface: Repository
Retrieves the objects contained in this repository that match the specified filter. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Specified by:
list in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
criteria - the filter to be used
Returns:
the objects contained in this repository that match the specified filter
See Also:
#setFirst(int)}, {@link #setLast(int)}, {@link #setOrder(String, boolean)}

list

public List<T> list(Specification<T> spec)
Description copied from interface: Repository
Retrieves the objects contained in this repository that satisfied the given specification. The order of the object inside the list depends on the "order" property. If "first" and "last" properties have been set only a part of the entities will be retrieved.

Specified by:
list in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
spec - the specification that must be satisfied
Returns:
the objects contained in this repository that satisfied the given specification

put

public void put(T object)
Description copied from interface: Repository
Add a new entity to this repository.

Specified by:
put in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
object - the entity you want to add

refresh

public void refresh(I objectId)
Description copied from interface: Repository
If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source. If the repository is not associated to an external data source or it has no local cache this method will have no effect.

Specified by:
refresh in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
objectId - the id of the object to be refreshed

refresh

public void refresh(T object)
Description copied from interface: Repository
If this repository is associated to an external data source (i.e a relational database) this method delete an object from the repository local cache so that a Repository.get(Serializable) will retrieve a fresh one from the data source. If the repository is not associated to an external data source or it has no local cache this method will have no effect.

Specified by:
refresh in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
object - the object to be refreshed

remove

public void remove(I objectId)
Description copied from interface: Repository
Removes an object from this repository. Before calling this method clients should check id this repository supports object removal using Repository.isRemoveAllowed()

Specified by:
remove in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
objectId - the id of the object to remove

remove

public void remove(T object)
Description copied from interface: Repository
Removes an object from this repository. Before calling this method clients should check id this repository supports object removal using Repository.isRemoveAllowed()

Specified by:
remove in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
object - the object to remove

setFirst

public void setFirst(int first)
Description copied from interface: Repository
Set the index of the first object that will be retrieved by Repository.list() and Repository.list(Filter) when value 0 has been set for 'first' in the filter.

The value in the filter, if different than 0, will always superseed this value.

Specified by:
setFirst in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
first - the index of the first object that will be retrieved by Repository.list() e Repository.list(Filter)

setLast

public void setLast(int last)
Description copied from interface: Repository
Set the index of the last object that will be retrieved by Repository.list() e Repository.list(Filter) when value 0 has been set for 'first' in the filter.

The value in the filter, if different than 0, will always superseed this value.

If the repository contains less objects than the indicated index, all the objects will be retrieved.

Specified by:
setLast in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
last - the index of the last object that will be retrieved by Repository.list() and Repository.list(Specification)

setOrder

public void setOrder(String property,
                     boolean reverse)
Description copied from interface: Repository
Set the order for the lists retrieved using Repository.list() and Repository.list(Specification). If a previous order property was set it will be replaced.

Specified by:
setOrder in interface Repository<I extends Serializable,T extends Entity<I>>
Parameters:
property - the name of the property that will be used to order the lists
reverse - if this parameter is true the order will be ascendant, otherwise it will be descendant


Copyright © 2011. All Rights Reserved.