Class LevelIdentifier


  • public final class LevelIdentifier
    extends Object
    The object identifying one level involved in a simulation.

    Usage

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

    Example

    The following code shows how to create the level identifiers for a simulation of the road traffic, containing a "Traffic" level where vehicles move in the infrastructure of the road network, and a "GPS" level where the GPS tells vehicles how they can navigate.

    public class LevelsOfRoadTrafficSimulation {
            public static final LevelIdentifier TRAFFICLEVEL = new LevelIdentifier( "Traffic level" );
            public static final LevelIdentifier GPSLEVEL = new LevelIdentifier( "GPS level" );
    }
    
    Author:
    Yoann Kubera
    • Constructor Detail

      • LevelIdentifier

        public LevelIdentifier​(String identifier)
        Builds an instance of this class using a specific value for the level identifier.
        Parameters:
        identifier - The identifier of the level. This value should be unique.
        Throws:
        IllegalArgumentException - If identifier is null.
    • Method Detail

      • toString

        public String toString()
        Gets a printable version of the level identifier.

        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 level identifier.
      • equals

        public boolean equals​(Object o)
        Check if this level identifier is equal to another level identifier.
        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 level identifiers 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.