Class GenericKeyedObjectPool.ObjectTimestampPair<T>

java.lang.Object
org.apache.commons.pool.impl.GenericKeyedObjectPool.ObjectTimestampPair<T>
All Implemented Interfaces:
Comparable<T>
Enclosing class:
GenericKeyedObjectPool<K,V>

static class GenericKeyedObjectPool.ObjectTimestampPair<T> extends Object implements Comparable<T>
A simple "struct" encapsulating an object instance and a timestamp. Implements Comparable, objects are sorted from old to new. This is also used by GenericObjectPool.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) long
    Deprecated.
    this field will be made private and final in version 2.0
    (package private) T
    Deprecated.
    this field will be made private and final in version 2.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new ObjectTimestampPair using the given object and the current system time.
    ObjectTimestampPair(T val, long time)
    Create a new ObjectTimeStampPair using the given object and timestamp value.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares this to another object by casting the argument to an ObjectTimestampPair.
    int
    Compares this to another ObjectTimestampPair, using the timestamp as basis for comparison.
    long
     
     
    Returns a string representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • value

      @Deprecated T value
      Deprecated.
      this field will be made private and final in version 2.0
      Object instance
    • tstamp

      @Deprecated long tstamp
      Deprecated.
      this field will be made private and final in version 2.0
      timestamp
  • Constructor Details

    • ObjectTimestampPair

      ObjectTimestampPair(T val)
      Create a new ObjectTimestampPair using the given object and the current system time.
      Parameters:
      val - object instance
    • ObjectTimestampPair

      ObjectTimestampPair(T val, long time)
      Create a new ObjectTimeStampPair using the given object and timestamp value.
      Parameters:
      val - object instance
      time - long representation of timestamp
  • Method Details

    • toString

      public String toString()
      Returns a string representation.
      Overrides:
      toString in class Object
      Returns:
      String representing this ObjectTimestampPair
    • compareTo

      public int compareTo(Object obj)
      Compares this to another object by casting the argument to an ObjectTimestampPair.
      Specified by:
      compareTo in interface Comparable<T>
      Parameters:
      obj - object to cmpare
      Returns:
      result of comparison
    • compareTo

      public int compareTo(GenericKeyedObjectPool.ObjectTimestampPair<T> other)
      Compares this to another ObjectTimestampPair, using the timestamp as basis for comparison. Implementation is consistent with equals.
      Parameters:
      other - object to compare
      Returns:
      result of comparison
    • getValue

      public T getValue()
      Returns:
      the value
    • getTstamp

      public long getTstamp()
      Returns:
      the tstamp