Class Role
java.lang.Object
madkit.kernel.Role
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Set<AgentAddress> The agent addresses.protected booleanThe modified.protected final GroupThe my group.The players. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns true if the agent is playing this rolebooleanexists()Returnstrueif the role is not emptyfinal List<AgentAddress> Returns a list of agent addresses corresponding to agents having the given rolegetAgentAddressOf(Agent agent) Returns the agent address of the agent in this roleReturns the community which this role belongs to.getGroup()Returns the group which this role belongs to.final StringgetName()Returns the role name.Returns the organization which this role belongs to.intsize()Returns the number of agents playing this roletoString()Returns a string representation that includes the community, group, and role names.
-
Field Details
-
players
-
agentAddresses
The agent addresses. -
modified
protected transient boolean modifiedThe modified. -
myGroup
The my group.
-
-
Method Details
-
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
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
nullif the agent is not in this role
-
getOrganization
Returns the organization which this role belongs to.- Returns:
- the parent organization of this role
-
getCommunity
Returns the community which this role belongs to.- Returns:
- the community which this role belongs to.
-
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()Returnstrueif the role is not empty- Returns:
trueif the role is not empty.
-
contains
Returns true if the agent is playing this role- Parameters:
agent- the agent to check- Returns:
trueif the agent is playing this role
-
getName
-
toString
-