Package info.monitorenter.util
Class TimeStampedValue
java.lang.Object
info.monitorenter.util.TimeStampedValue
- All Implemented Interfaces:
Comparable<TimeStampedValue>
,Map.Entry<Long,
Object>
public final class TimeStampedValue
extends Object
implements Map.Entry<Long,Object>, Comparable<TimeStampedValue>
Simple wrapper around a time in ms and a value Object.
The key is the time in ms and may be used in a Map.
compares the key.compareTo(TimeStampedValue)
- Version:
- $Revision: 1.11 $
- Author:
- Achim Westermann
-
Constructor Summary
ConstructorsConstructorDescriptionTimeStampedValue
(long key, Object value) Creates an instance with the given timestamp key and the value to time stamp.TimeStampedValue
(Object value) Creates an instance for the given value that is time stamped with the current time. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares the givenTimeStampedValue
to this by the internalgetTime()
.boolean
getKey()
Returns theLong
that marks the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).long
getTime()
Returns the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).getValue()
Returns the time stamp.int
hashCode()
boolean
isPast()
Returns whether the internal time stamp marks a time in the past or not.Assigns a different value to the timestamp.
-
Constructor Details
-
TimeStampedValue
Creates an instance with the given timestamp key and the value to time stamp.- Parameters:
key
- the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).value
- the value to time stamp.
-
TimeStampedValue
Creates an instance for the given value that is time stamped with the current time.- Parameters:
value
- the value to time stamp.- See Also:
-
-
Method Details
-
compareTo
Compares the givenTimeStampedValue
to this by the internalgetTime()
.- Specified by:
compareTo
in interfaceComparable<TimeStampedValue>
- Parameters:
obj
- the object to compare this to.- Returns:
- see interface.
- See Also:
-
equals
-
getKey
Returns theLong
that marks the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC). -
getTime
public long getTime()Returns the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).- Returns:
- the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).
-
getValue
Returns the time stamp. -
hashCode
public int hashCode() -
isPast
public boolean isPast()Returns whether the internal time stamp marks a time in the past or not.For normal a time stamp represents a value regarded at a time. But it is also thinkable to mark a value for expiration in the future. This method returns true if the internal time- representing key is smaller than the actual time.
- Returns:
- true if the internal time stamp marks a moment in the past, false else.
-
setValue
Assigns a different value to the timestamp.
-