public class AgentAddress
extends java.lang.Object
implements java.io.Serializable
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.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object agentAddress)
Tells if another address is the same.
|
java.lang.String |
getAgentNetworkID()
Return a string representing a unique identifier of the binded agent
over the network.
|
java.lang.String |
getCommunity()
Returns the community to which this agent address is binded to.
|
java.lang.String |
getGroup()
Returns the group to which this agent address is binded to.
|
KernelAddress |
getKernelAddress() |
java.lang.String |
getRole()
Returns the role to which this agent address is binded to.
|
java.lang.String |
getSimpleAgentNetworkID()
Return a string representing a shorter version of the
unique identifier of the binded agent over the network.
|
int |
hashCode()
The hash code of an agent address.
|
boolean |
isFrom(KernelAddress kernel)
Tells if the address is from a specific kernel.
|
java.lang.String |
toString()
Returns a string representing this address.
|
public KernelAddress getKernelAddress()
public java.lang.String getCommunity()
public java.lang.String getGroup()
public java.lang.String getRole()
public java.lang.String toString()
KernelAddress
to which this address belongs to.toString
in class java.lang.Object
public boolean equals(java.lang.Object agentAddress) throws java.lang.ClassCastException
true
, this means that both addresses refer to
the same agent considering the same position in the artificial society.equals
in class java.lang.Object
agentAddress
- the address to compare.java.lang.ClassCastException
- On purpose,
if the address is compared to an object with another type
which is considered as a programming error.public final int hashCode()
AbstractAgent.hashCode()
hashCode
in class java.lang.Object
public boolean isFrom(KernelAddress kernel)
true
,
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.
kernel
- the kernel address against which this address should be tested.true
if this address belongs to the corresponding kernel.public final java.lang.String getAgentNetworkID()
public final java.lang.String getSimpleAgentNetworkID()
AbstractAgent.getSimpleNetworkID()
Fabien Michel, Olivier Gutknecht, Jacques Ferber - November 18 2014