org.qi4j.api.entity.association
Interface NamedAssociation<T>

Type Parameters:
T - The type of the NamedAssociation.
All Superinterfaces:
AbstractAssociation, AssociationInfo, Iterable<String>

public interface NamedAssociation<T>
extends AbstractAssociation, Iterable<String>

A NamedAssociation can be looked-up in its local context (the set of associations) via a name (java.lang.String).

The Iterable<String&ht; returns the names in the association set.


Method Summary
 String contains(T entity)
          Checks if the entity is present.
 boolean containsKey(String name)
          Checks if there is an association with the given name.
 int count()
           
 T get(String name)
          Retrieves a named association.
 Iterable<String> names()
          Returns the names in this set of association.
 void put(String name, T entity)
          Adds an assocation.
 Map<String,T> toMap()
          Converts this NamedAssociation into a standard Java Map.
 
Methods inherited from interface org.qi4j.api.entity.association.AssociationInfo
isAggregated, isImmutable, metaInfo, qualifiedName, type
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

put

void put(String name,
         T entity)
Adds an assocation.

Parameters:
name - The name of the associated entity.
entity - The entity for this named association.

get

T get(String name)
Retrieves a named association.

Parameters:
name - The name of the association.
Returns:
The entity that has previously been associated.

count

int count()
Returns:
The number of named associations in this NamedAssociation (i.e. local context).

containsKey

boolean containsKey(String name)
Checks if there is an association with the given name.

Parameters:
name - The name of the association we are checking if it exists.
Returns:
true if it exists, false otherwise.

contains

String contains(T entity)
Checks if the entity is present. Note that this is potentially a very slow operation, depending on the size of the NamedAssociation.

Parameters:
entity - The entity to look for.
Returns:
The name of the entity if found, otherwise null.

names

Iterable<String> names()
Returns the names in this set of association.

Returns:
The names of the associations that has been entered already.

toMap

Map<String,T> toMap()
Converts this NamedAssociation into a standard Java Map.

Returns:
A fully populated Map with the content of this NamedAssociation.