Class Role

java.lang.Object
madkit.kernel.Role
All Implemented Interfaces:
Serializable

public class Role extends Object implements Serializable
Reifying the notion of Role in AGR. A Role is a set of agents playing a specific function in a group.

Especially, a role maintains a list of agents playing it, and the corresponding agent addresses.

See Also:
  • Field Details

    • players

      protected final transient Set<Agent> players
      The players.
    • agentAddresses

      protected transient Set<AgentAddress> agentAddresses
      The agent addresses.
    • modified

      protected transient boolean modified
      The modified.
    • myGroup

      protected final transient Group myGroup
      The my group.
  • Method Details

    • getAgentAddresses

      public final List<AgentAddress> getAgentAddresses()
      Returns a list of agent addresses corresponding to agents having the given role
      Returns:
      the list of agent addresses corresponding to agents having the given role
    • getAgentAddressOf

      public AgentAddress getAgentAddressOf(Agent agent)
      Returns the agent address of the agent in this role
      Parameters:
      agent - the agent to check
      Returns:
      the agent address of the agent in this role, or null if the agent is not in this role
    • getOrganization

      public Organization getOrganization()
      Returns the organization which this role belongs to.
      Returns:
      the parent organization of this role
    • getCommunity

      public Community getCommunity()
      Returns the community which this role belongs to.
      Returns:
      the community which this role belongs to.
    • getGroup

      public Group getGroup()
      Returns the group which this role belongs to.
      Returns:
      the group which this role belongs to.
    • size

      public int size()
      Returns the number of agents playing this role
      Returns:
      the number of agents playing this role
    • exists

      public boolean exists()
      Returns true if the role is not empty
      Returns:
      true if the role is not empty.
    • contains

      public final boolean contains(Agent agent)
      Returns true if the agent is playing this role
      Parameters:
      agent - the agent to check
      Returns:
      true if the agent is playing this role
    • getName

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

      public String toString()
      Returns a string representation that includes the community, group, and role names.
      Overrides:
      toString in class Object
      Returns:
      the string representation of the role.