org.tmapi.core
Interface Association

All Superinterfaces:
Construct, Reifiable, Scoped, Typed

public interface Association
extends Reifiable, Typed, Scoped

Represents an association item.

Version:
$Rev: 123 $ - $Date: 2009-10-01 19:17:03 +0200 (Do, 01 Okt 2009) $
Author:
The TMAPI Project

Method Summary
 Role createRole(Topic type, Topic player)
          Creates a new Role representing a role in this association.
 TopicMap getParent()
          Returns the topic map to which this association belongs.
 java.util.Set<Role> getRoles()
          Returns the roles participating in this association.
 java.util.Set<Role> getRoles(Topic type)
          Returns all roles with the specified type.
 java.util.Set<Topic> getRoleTypes()
          Returns the role types participating in this association.
 
Methods inherited from interface org.tmapi.core.Reifiable
getReifier, setReifier
 
Methods inherited from interface org.tmapi.core.Typed
getType, setType
 
Methods inherited from interface org.tmapi.core.Scoped
addTheme, getScope, removeTheme
 
Methods inherited from interface org.tmapi.core.Construct
addItemIdentifier, equals, getId, getItemIdentifiers, getTopicMap, hashCode, remove, removeItemIdentifier
 

Method Detail

getParent

TopicMap getParent()
Returns the topic map to which this association belongs.

Specified by:
getParent in interface Construct
Returns:
The topic map to which this association belongs.
See Also:
Construct.getParent()

getRoles

java.util.Set<Role> getRoles()
Returns the roles participating in this association. The return value may be empty but must never be null.

Returns:
An unmodifiable set of Roles.

getRoleTypes

java.util.Set<Topic> getRoleTypes()
Returns the role types participating in this association.

This method returns the same result as the following code:

      Set<Topic> types = new HashSet<Topic>();
      for (Role role: assoc.getRoles()) {
          types.add(role.getType());
      }
 

The return value may be empty but must never be null.

Returns:
An unmodifiable set of role types.

getRoles

java.util.Set<Role> getRoles(Topic type)
Returns all roles with the specified type.

This method returns the same result as the following code:

      Set<Role> roles = new HashSet<Role>();
      for (Role role: assoc.getRoles()) {
          if (role.getType().equals(type)) {
              roles.add(role);
          }
      }
 

The return value may be empty but must never be null.

Parameters:
type - The type of the Role instances to be returned, must not be null.
Returns:
An unmodifiable (maybe empty) set of roles with the specified type property.
Throws:
java.lang.IllegalArgumentException - In case the type is null.

createRole

Role createRole(Topic type,
                Topic player)
                throws ModelConstraintException
Creates a new Role representing a role in this association.

Parameters:
type - The role type; MUST NOT be null.
player - The role player; MUST NOT be null.
Returns:
A newly created association role.
Throws:
ModelConstraintException - In case the role type or player is null.