org.egothor.cache
Class AbstractNode<K,T>

java.lang.Object
  extended by org.egothor.cache.AbstractNode<K,T>
Type Parameters:
K - type of the key
T - type of the implementing class (used for Comparable)
All Implemented Interfaces:
java.lang.Comparable<T>
Direct Known Subclasses:
LfuNode, LruKNode

public abstract class AbstractNode<K,T>
extends java.lang.Object
implements java.lang.Comparable<T>

Represents a node that can be used as a key for TreeMap.


Field Summary
protected  K key
          Key associated with the node.
 
Constructor Summary
protected AbstractNode(K key)
          Constructor for the AbstractNode.
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks whether the specified object is an AbstractNode with the same key.
 K getKey()
          Gets the associated key.
 int hashCode()
          Computes the hash code for the node as a hash code of the key.
 java.lang.String toString()
          Returns a text representation of the node.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

key

protected K key
Key associated with the node.

Constructor Detail

AbstractNode

protected AbstractNode(K key)
Constructor for the AbstractNode. Stores the key parameter.

Parameters:
key - key associated with the node.
Method Detail

getKey

public K getKey()
Gets the associated key.

Returns:
key associated with the node

equals

public boolean equals(java.lang.Object o)
Checks whether the specified object is an AbstractNode with the same key.

Overrides:
equals in class java.lang.Object
Returns:
true, if the specified object is an AbstractNode with the same key, or fale otherwise

hashCode

public int hashCode()
Computes the hash code for the node as a hash code of the key.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code of the node

toString

public java.lang.String toString()
Returns a text representation of the node.

Overrides:
toString in class java.lang.Object
Returns:
text representation of the node