Class RoleMultiple

  • All Implemented Interfaces:
    Serializable

    public class RoleMultiple
    extends Object
    implements Serializable
    This structure provides code for managing target agents registering in a role. A notification may be sent to a role using the sendTo function of the sending agent. The class does not handle duplicates in the list.
    See Also:
    Serialized Form
    • Constructor Detail

      • RoleMultiple

        public RoleMultiple()
      • RoleMultiple

        public RoleMultiple​(String name)
        Creates a new RoleMultiple with a specified name.
        Parameters:
        name - the role name.
    • Method Detail

      • addListener

        public void addListener​(AgentId target)
        Adds an agent in the listeners list.
        Parameters:
        target - the identifier of agent to add.
      • removeListener

        public void removeListener​(AgentId target)
        Removes an agent from the listeners list.
        Parameters:
        target - the identifier of agent to remove.
      • getListeners

        public Enumeration<AgentId> getListeners()
        Gets the listeners list as an Enumeration of AgentId objects. There is no synchronization as we assume this object is manipulated from the enclosing agent reaction.
        Returns:
        the listeners list of AgentId.
      • getName

        public String getName()
        Returns the role name.
        Returns:
        the role name.
      • setName

        public void setName​(String name)
        Sets the role name.
        Parameters:
        name - the role name.
      • contains

        public boolean contains​(AgentId id)
        Tests if the specified agent id belongs to role multiple.
        Parameters:
        id - the specified agent id.
        Returns:
        true if the specified id belongs to the role; false otherwise.
      • toString

        public String toString()
        Provides a string image for this object.
        Overrides:
        toString in class Object