Class SimulationTimeStamp
- java.lang.Object
-
- fr.univ_artois.lgi2a.similar.microkernel.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 Summary
Constructors Constructor Description SimulationTimeStamp(long identifier)
Builds a time stamp having a specific identifier.SimulationTimeStamp(SimulationTimeStamp toCopy)
Builds a time stamp as a copy of another time stamp.SimulationTimeStamp(SimulationTimeStamp reference, int shift)
Builds a time stamp which identifier is defined relatively to the identifier of another time stamp.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Creates a copy of this object, having the same identifier.long
compareToTimeStamp(SimulationTimeStamp otherTimeStamp)
Compares the identifier of this time stamp to the identifier of another time stamp.boolean
equals(Object obj)
Returnstrue
if this object models the same time stamp than the parameter.long
getIdentifier()
Gets the unique identifier of this time stamp.int
hashCode()
Returns a hash code value for this object.String
toString()
-
-
-
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 isnull
.
-
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 isnull
.ArithmeticException
- If the identifier of the new time stamp exceeds the capacity of theLong
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 isnull
.
-
hashCode
public int hashCode()
Returns a hash code value for this object. This hash code is built using theidentifier
field of this class.- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object obj)
Returnstrue
if this object models the same time stamp than the parameter. Two time stamps are identical if their identifiers are equal.- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
clone
public Object clone()
Creates a copy of this object, having the same identifier.- Overrides:
clone
in classObject
- Returns:
- A copy of this object.
- See Also:
Object.clone()
-
-