Class AgentCategory
- java.lang.Object
-
- fr.univ_artois.lgi2a.similar.microkernel.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 Summary
Constructors Constructor Description AgentCategory(String identifier, AgentCategory... parents)
Builds an instance of this class using a specific value for the agent category.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Check if this agent category is equal to another agent category.int
hashCode()
Gets the hash code of this object.boolean
isA(AgentCategory category)
Determines if an agent having this category is considered as belonging to the category provided in parameter.String
toString()
Gets a printable version of the agent category.
-
-
-
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
- Ifidentifier
isnull
.
-
-
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.
-
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.
-
-