Package madkit.kernel
Class AgentAddress
java.lang.Object
madkit.kernel.AgentAddress
- All Implemented Interfaces:
Serializable
Identifies an agent within the artificial society.
How this class works is very different from the previous versions of MaDKit. More precisely, it now 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
AbstractAgent.sendMessage(AgentAddress, Message)
will not be
delivered if the agent has leaved the related CGR location.
- Since:
- MaDKit 1.0
- Version:
- 5.1
- Author:
- Olivier Gutknecht, Fabien Michel
- 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 agent address is binded to.getGroup()
Returns the group to which this agent address is binded to.getRole()
Returns the role to which this agent address is binded to.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
isFrom
(KernelAddress kernel) Tells if the address is from a specific kernel.toString()
Returns a string representing this address.
-
Method Details
-
getKernelAddress
- Returns:
- the platform's kernelAddress to which this agent address comes from
-
getCommunity
Returns the community to which this agent address is binded to.- Returns:
- the name of the community to which this agent address belongs to
- Since:
- MaDKit 5
-
getGroup
Returns the group to which this agent address is binded to.- Returns:
- the name of the group to which this agent address belongs to
- Since:
- MaDKit 5
-
getRole
Returns the role to which this agent address is binded to.- Returns:
- the role name to which this agent address belongs to
- 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 to. -
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.
-
hashCode
public final int hashCode()The hash code of an agent address. It is the same as the underlying agent's. SeeAbstractAgent.hashCode()
-
isFrom
Tells if the address is from a specific kernel. Iftrue
, This means that the agent to which this address belongs to is located on the tested kernel. So, it is just a shortcut for *return getKernelAddress().equals(kernel);
for which this address has been created was running on the local kernel.- Parameters:
kernel
- the kernel address against which this address should be tested.- Returns:
true
if this address belongs to the corresponding kernel.- Since:
- MaDKit 5.0.4
-
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
- See Also:
-