javax.cache
Interface Cache.Entry<K,V>

Enclosing interface:
Cache<K,V>

public static interface Cache.Entry<K,V>

A cache entry (key-value pair).


Method Summary
 boolean equals(Object o)
          Compares the specified object with this entry for equality.
 K getKey()
          Returns the key corresponding to this entry.
 V getValue()
          Returns the value stored in the cache when this entry was created.
 int hashCode()
          Returns the hash code value for this cache entry.
 

Method Detail

getKey

K getKey()
Returns the key corresponding to this entry.

Returns:
the key corresponding to this entry

getValue

V getValue()
Returns the value stored in the cache when this entry was created.

Returns:
the value corresponding to this entry

equals

boolean equals(Object o)
Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping. More formally, two entries e1 and e2 represent the same mapping if
     e1.getKey().equals(e2.getKey())  &&
     e1.getValue().equals(e2.getValue())
 
This ensures that the equals method works properly across different implementations of the Cache.Entry interface.

Overrides:
equals in class Object
Parameters:
o - object to be compared for equality with this cache entry
Returns:
true if the specified object is equal to this cache entry

hashCode

int hashCode()
Returns the hash code value for this cache entry. The hash code of a cache entry e is defined to be:
     e.getKey().hashCode() ^
     e.getValue().hashCode()
 
This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.

Overrides:
hashCode in class Object
Returns:
the hash code value for this cache entry
See Also:
Object.hashCode(), Object.equals(Object), equals(Object)


Copyright © 2011. All Rights Reserved.