org.vizzini.game
Class AgentCollection

java.lang.Object
  extended by org.vizzini.util.AbstractCollection
      extended by org.vizzini.util.AbstractMap
          extended by org.vizzini.game.AgentCollection
All Implemented Interfaces:
PropertyChangeListener, Serializable, Cloneable, Iterable, Collection, EventListener, IAgentCollection, ICollection

public class AgentCollection
extends AbstractMap
implements IAgentCollection, PropertyChangeListener

Provides a collection to hold IAgent s. Each stored agent's name and team combination must be unique, as name and team are the only discriminating properties.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
IAgent, AbstractAgent.equals(Object), Serialized Form

Constructor Summary
AgentCollection()
           
 
Method Summary
 boolean add(Object object)
          Add the given object.
 void clear()
          Removes all of the objects from this collection.
 int count(Class type)
          Return the count of agents in this collection of the given type.
 IAgent findByName(String name)
          Return the agent with the given name.
 IAgent findByTeam(ITeam team)
          Return the first agent with the given team.
 IAgent firstOpponent(IAgent agent)
          Return the first found agent opponent to the given agent.
 IAgent get(Class agentType)
          Return the first agent found of the given type.
protected  Map getAgentToOpponents()
          Return the map of agents to opponents.
protected  Map getData()
          Return the data collection.
protected  Object getKey(Object object)
          Return the agent key.
protected  Object getKey(String name, String teamName)
          Return the agent key.
protected  Class getType()
          Return the type this collection holds.
 Iterator opponentIterator(IAgent agent)
          Return an iterator over all the agents excepting the given agent.
 void propertyChange(PropertyChangeEvent event)
          Implement a property change listener for relevant token properties.
 boolean remove(Object object)
          Add the given object.
 
Methods inherited from class org.vizzini.util.AbstractMap
contains, equals, hashCode, isEmpty, iterator, size, toString
 
Methods inherited from class org.vizzini.util.AbstractCollection
addAll, containsAll, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.util.ICollection
toString
 
Methods inherited from interface java.util.Collection
addAll, contains, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

AgentCollection

public AgentCollection()
Method Detail

add

public boolean add(Object object)
Add the given object. Extend the super method to add property listeners to the token.

Specified by:
add in interface Collection
Overrides:
add in class AbstractMap
Since:
v0.2

clear

public void clear()
Removes all of the objects from this collection.

Specified by:
clear in interface Collection
Overrides:
clear in class AbstractMap
Since:
v0.3

count

public int count(Class type)
Return the count of agents in this collection of the given type.

Specified by:
count in interface IAgentCollection
Parameters:
type - Agent class.
Since:
v0.2

findByName

public IAgent findByName(String name)
Return the agent with the given name.

Specified by:
findByName in interface IAgentCollection
Since:
v0.1

findByTeam

public IAgent findByTeam(ITeam team)
Return the first agent with the given team.

Specified by:
findByTeam in interface IAgentCollection
Since:
v0.3

firstOpponent

public IAgent firstOpponent(IAgent agent)
Return the first found agent opponent to the given agent.

Specified by:
firstOpponent in interface IAgentCollection
Parameters:
agent - Agent.
Since:
v0.3

get

public IAgent get(Class agentType)
Return the first agent found of the given type.

Since:
v0.1

opponentIterator

public Iterator opponentIterator(IAgent agent)
Return an iterator over all the agents excepting the given agent.

Specified by:
opponentIterator in interface IAgentCollection
Parameters:
agent - The agent to omit from the iterator.
Since:
v0.1

propertyChange

public void propertyChange(PropertyChangeEvent event)
Implement a property change listener for relevant token properties. This method re-maps an agent if the agent's name or team has changed.

Specified by:
propertyChange in interface PropertyChangeListener
Since:
v0.2

remove

public boolean remove(Object object)
Add the given object. Extend the super method to remove property listeners from the token.

Specified by:
remove in interface Collection
Overrides:
remove in class AbstractMap
Since:
v0.2

getAgentToOpponents

protected Map getAgentToOpponents()
Return the map of agents to opponents.

Since:
v0.3

getData

protected Map getData()
Return the data collection.

Specified by:
getData in class AbstractMap
Since:
v0.1

getKey

protected Object getKey(Object object)
Return the agent key.

Specified by:
getKey in class AbstractMap
Since:
v0.1

getKey

protected Object getKey(String name,
                        String teamName)
Return the agent key.

Since:
v0.1

getType

protected Class getType()
Return the type this collection holds.

Specified by:
getType in class AbstractCollection
Since:
v0.1


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02