Class AgentAddress
java.lang.Object
madkit.kernel.AgentAddress
- All Implemented Interfaces:
Serializable
This class represents an address an agent can have within the artificial society. It
represents the agent's position in the artificial society.
More precisely, it corresponds to a CGR location (community;group;role) where the agent is in. So, an agent may have several AgentAddress as it could join many CGR locations.
Moreover, if the related agent leaves the corresponding CGR location, then an
AgentAddress becomes invalid and no longer permits to reach this agent. For instance, a
message sent using Agent.send(Message, AgentAddress)
will not be delivered if
the agent has leaved the related CGR location.
- Since:
- MaDKit 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Tells if another address is the same.final String
Return a string representing a unique identifier of the binded agent over the network.Returns the community to which this AgentAddress is bound.getGroup()
Returns the group to which this AgentAddress is bound.Returns the kernel address associated with this AgentAddress.getRole()
Returns the role to which this AgentAddress is bound.final String
Return a string representing a shorter version of the unique identifier of the binded agent over the network.final int
hashCode()
The hash code of an agent address.boolean
isValid()
Checks if this AgentAddress is valid.toString()
Returns a string representing this address.
-
Method Details
-
getKernelAddress
Returns the kernel address associated with this AgentAddress.- Returns:
- the kernel address associated with this AgentAddress
-
getCommunity
Returns the community to which this AgentAddress is bound.- Returns:
- the name of the community to which this AgentAddress belongs
- Since:
- MaDKit 5
-
getGroup
Returns the group to which this AgentAddress is bound.- Returns:
- the name of the group to which this AgentAddress belongs
- Since:
- MaDKit 5
-
getRole
Returns the role to which this AgentAddress is bound.- Returns:
- the role name to which this AgentAddress belongs
- Since:
- MaDKit 5
-
toString
Returns a string representing this address. This string contains the ID of the owner agent, the CGR location of this address and theKernelAddress
to which this address belongs. -
equals
Tells if another address is the same. Iftrue
, this means that both addresses refer to the same agent considering the same position in the artificial society.- Overrides:
equals
in classObject
- Parameters:
agentAddress
- the address to compare.- Throws:
ClassCastException
- On purpose, if the address is compared to an object with another type which is considered as a programming error.
-
isValid
public boolean isValid()Checks if this AgentAddress is valid. Returnstrue
if the corresponding agent is still playing the associated role.- Returns:
true
if this AgentAddress is valid,false
otherwise
-
hashCode
public final int hashCode()The hash code of an agent address. It is the same as the underlying agent's. SeeAgent.hashCode()
-
getAgentNetworkID
Return a string representing a unique identifier of the binded agent over the network.- Returns:
- the agent's network identifier
-
getSimpleAgentNetworkID
Return a string representing a shorter version of the unique identifier of the binded agent over the network. As a simplified version, this string may not be unique.- Returns:
- a simplified version of the binded agent's network identifier
-