Class SimulationTimeStamp

  • All Implemented Interfaces:
    Serializable, Cloneable

    public final class SimulationTimeStamp
    extends Object
    implements Serializable, Cloneable
    Models a time stamp (i.e. the beginning of a time step) of the simulation.

    Correspondence with theory

    In the theory of similar, an instance of this class models an element from the 𝕋 set of time stamps.

    Usage

    Each time stamp has a unique identifier, modeled as a long value. This identifier is used to order time stamps the ones relatively to the others.

    Author:
    Yoann Kubera, Gildas Morvan
    See Also:
    Serialized Form
    • Constructor Detail

      • SimulationTimeStamp

        public SimulationTimeStamp​(long identifier)
        Builds a time stamp having a specific identifier.
        Parameters:
        identifier - The identifier of the time stamp.
      • SimulationTimeStamp

        public SimulationTimeStamp​(SimulationTimeStamp toCopy)
        Builds a time stamp as a copy of another time stamp.
        Parameters:
        toCopy - The time stamp to copy.
        Throws:
        IllegalArgumentException - If the argument is null.
      • SimulationTimeStamp

        public SimulationTimeStamp​(SimulationTimeStamp reference,
                                   int shift)
        Builds a time stamp which identifier is defined relatively to the identifier of another time stamp.
        Parameters:
        reference - The time stamp used as a reference to create the identifier of the new time stamp.
        shift - The value added to the identifier of the reference to obtain the identifier of the new time stamp.
        Throws:
        IllegalArgumentException - If the argument is null.
        ArithmeticException - If the identifier of the new time stamp exceeds the capacity of the Long type.
    • Method Detail

      • getIdentifier

        public long getIdentifier()
        Gets the unique identifier of this time stamp.
        Returns:
        The unique identifier of this time stamp.
      • compareToTimeStamp

        public long compareToTimeStamp​(SimulationTimeStamp otherTimeStamp)
        Compares the identifier of this time stamp to the identifier of another time stamp.
        Parameters:
        otherTimeStamp - The other time stamp used in the comparison.
        Returns:
        the difference between the identifier of this time stamp and the identifier of the parameter:
        • 0 if the identifiers are identical
        • a negative value if the identifier of this time stamp is lesser than the identifier of the time stamp of the parameter
        • a positive value if the identifier of this time stamp is greater than the identifier of the time stamp of the parameter
        Throws:
        IllegalArgumentException - If the parameter is null.
      • hashCode

        public int hashCode()
        Returns a hash code value for this object. This hash code is built using the identifier field of this class.
        Overrides:
        hashCode in class Object
        See Also:
        Object.hashCode()
      • equals

        public boolean equals​(Object obj)
        Returns true if this object models the same time stamp than the parameter. Two time stamps are identical if their identifiers are equal.
        Overrides:
        equals in class Object
        See Also:
        Object.equals(java.lang.Object)
      • clone

        public Object clone()
        Creates a copy of this object, having the same identifier.
        Overrides:
        clone in class Object
        Returns:
        A copy of this object.
        See Also:
        Object.clone()