it.amattioli.dominate.groups
Class EntityGroup<I extends Serializable,T extends Entity<I>>

Show UML class diagram
java.lang.Object
  extended by it.amattioli.dominate.groups.EntityGroup<I,T>
Type Parameters:
I -
T -

public class EntityGroup<I extends Serializable,T extends Entity<I>>
extends Object

Represents a group of entities that satisfies a specification.

Author:
andrea

Constructor Summary
EntityGroup(Repository<I,T> rep, Specification<T> spec, String description)
          Construct a group given a repository and a specification.
EntityGroup(Specification<T> spec, String description)
          Construct a group given a specification.
 
Method Summary
 boolean add(T toBeAdded)
          Add an entity to this group.
 boolean contains(T e)
          Check if this group contains an entity.
 String getDescription()
          Retrieves the description of this group
 T getMember(int index)
          Retrieves a member of the group.
 List<T> list()
          Retrieves all the members of this group.
 int size()
          Return the number of members contained in this group
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityGroup

public EntityGroup(Repository<I,T> rep,
                   Specification<T> spec,
                   String description)
Construct a group given a repository and a specification. The group will contain all the entities of the repository that satisfy the specification.

Parameters:
rep - the repository from which the entities will be loaded
spec - the specification that must be satisfied by the members of this group
description - the description of this group

EntityGroup

public EntityGroup(Specification<T> spec,
                   String description)
Construct a group given a specification. The group will initially be empty and must be filled using add(Entity).

Parameters:
spec - the specification that must be satisfied by the members of this group
description - the description of this group
Method Detail

getMember

public T getMember(int index)
Retrieves a member of the group.

Parameters:
index - the index of the member in the list returned by list()
Returns:
the member of the group with the given index

contains

public boolean contains(T e)
Check if this group contains an entity.

Parameters:
e - the entity to be checked
Returns:
true if this group contains the given entity

size

public int size()
Return the number of members contained in this group

Returns:
the number of members contained in this group

list

public List<T> list()
Retrieves all the members of this group.

Returns:
all the members of this group.

add

public boolean add(T toBeAdded)
Add an entity to this group. The entity will actually be added only if it satisfies the group specification.

Parameters:
toBeAdded - the entity to be added to this group
Returns:
true if the given entity was added to this group

getDescription

public String getDescription()
Retrieves the description of this group

Returns:
the description of this group


Copyright © 2011. All Rights Reserved.