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. compareTo(TimeStampedValue) compares the key.

Version:
$Revision: 1.11 $
Author:
Achim Westermann
  • Constructor Details

    • TimeStampedValue

      public TimeStampedValue(long key, Object value)
      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

      public TimeStampedValue(Object value)
      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

      public int compareTo(TimeStampedValue obj)
      Compares the given TimeStampedValue to this by the internal getTime().

      Specified by:
      compareTo in interface Comparable<TimeStampedValue>
      Parameters:
      obj - the object to compare this to.
      Returns:
      see interface.
      See Also:
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map.Entry<Long,Object>
      Overrides:
      equals in class Object
      See Also:
    • getKey

      public Long getKey()
      Returns the Long that marks the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).
      Specified by:
      getKey in interface Map.Entry<Long,Object>
      Returns:
      the Long that marks the time stamp (difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC).
      See Also:
    • 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

      public Object getValue()
      Returns the time stamp.

      Specified by:
      getValue in interface Map.Entry<Long,Object>
      Returns:
      the time stamp.
      See Also:
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map.Entry<Long,Object>
      Overrides:
      hashCode in class Object
      See Also:
    • 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

      public Object setValue(Object value)
      Assigns a different value to the timestamp.

      Specified by:
      setValue in interface Map.Entry<Long,Object>
      Parameters:
      value - the new value to be marked with this timestamp.
      Returns:
      the previous value that was contained.
      See Also: