Class AgentAddress

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

public class AgentAddress extends Object implements 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 Details

    • getKernelAddress

      public KernelAddress getKernelAddress()
      Returns the kernel address associated with this AgentAddress.
      Returns:
      the kernel address associated with this AgentAddress
    • getCommunity

      public String 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

      public String 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

      public String getRole()
      Returns the role to which this AgentAddress is bound.
      Returns:
      the role name to which this AgentAddress belongs
      Since:
      MaDKit 5
    • toString

      public String toString()
      Returns a string representing this address. This string contains the ID of the owner agent, the CGR location of this address and the KernelAddress to which this address belongs.
      Overrides:
      toString in class Object
      Returns:
      a description of this address.
    • equals

      public boolean equals(Object agentAddress) throws ClassCastException
      Tells if another address is the same. If true, this means that both addresses refer to the same agent considering the same position in the artificial society.
      Overrides:
      equals in class Object
      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. Returns true 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. See Agent.hashCode()
      Overrides:
      hashCode in class Object
    • getAgentNetworkID

      public final String getAgentNetworkID()
      Return a string representing a unique identifier of the binded agent over the network.
      Returns:
      the agent's network identifier
    • getSimpleAgentNetworkID

      public final String 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