Class AgentCategory


  • public final class AgentCategory
    extends Object
    The object identifying the category of an agent involved in a simulation.

    Role

    To facilitate the access to agent categories, it is recommended to create a class containing each agent category of the simulation as a static value. This avoids any misspelling when referring to a level.

    Usage example

    The following code shows how to create the agent categories for a simulation of the road traffic, containing a "Vehicle" and "Pedestrian" agent categories.

    public class CategoriesOfRoadTrafficSimulation {
            public static final AgentCategory VEHICLE = new AgentCategory( "Vehicle" );
            public static final AgentCategory PEDESTRIAN = new AgentCategory( "Pedestrian" );
    }
    
    Author:
    Yoann Kubera, Gildas Morvan
    • Constructor Detail

      • AgentCategory

        public AgentCategory​(String identifier,
                             AgentCategory... parents)
        Builds an instance of this class using a specific value for the agent category.
        Parameters:
        identifier - The identifier of the agent category. This value should be unique.
        parents - The identifiers of the direct parents of this category.For instance, when creating a turmite agent category, you can specify that a turmite is a turtle and therefore also belongs to the turtle agent category, by adding this category in this constructor argument.
        Throws:
        IllegalArgumentException - If identifier is null.
    • Method Detail

      • toString

        public String toString()
        Gets a printable version of the agent category.

        This identifier is used in the various simulation traces defined in the common libraries.

        Overrides:
        toString in class Object
        Returns:
        A string representation of the agent category.
      • isA

        public boolean isA​(AgentCategory category)
        Determines if an agent having this category is considered as belonging to the category provided in parameter.
        Parameters:
        category - The category to check.
        Returns:
        true if an agent having this category is considered as belonging to the category provided in parameter.
      • equals

        public boolean equals​(Object o)
        Check if this agent category is equal to another agent category.
        Overrides:
        equals in class Object
        Parameters:
        o - The other object used to check equality.
        Returns:
        true if the two objects are equal, i.e. if they are both agent category having the same string identifier.
      • hashCode

        public int hashCode()
        Gets the hash code of this object.
        Overrides:
        hashCode in class Object
        Returns:
        The hash code of this object.