net.cscott.jutil

Class AbstractMapEntry<K,V>

public abstract class AbstractMapEntry<K,V> extends Object implements Entry<K,V>

An AbstractMapEntry takes care of most of the grunge work involved in subclassing java.util.Map.Entry. For an immutable entry, you need only implement getKey() and getValue(). For a modifiable entry, you must also implement setValue(); the default implementation throws an UnsupportedOperationException.

Version: $Id: AbstractMapEntry.java,v 1.1 2003/03/20 01:58:20 cananian Exp $

Author: C. Scott Ananian

Method Summary
booleanequals(Object o)
Compares the specified object with this entry for equality.
abstract KgetKey()
Returns the key corresponding to this entry.
abstract VgetValue()
Returns the value corresponding to this entry.
inthashCode()
Returns the hash code value for this map entry.
VsetValue(V value)
Replaces the value corresponding to this entry with the specified value (optional operation).
StringtoString()
Returns a human-readable representation of this map entry.

Method Detail

equals

public 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.

getKey

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

getValue

public abstract V getValue()
Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove() operation), the results of this call are undefined.

hashCode

public int hashCode()
Returns the hash code value for this map entry.

setValue

public V setValue(V value)
Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove() operation).

Returns: old value corresponding to entry.

toString

public String toString()
Returns a human-readable representation of this map entry.
Copyright © 2003 C. Scott Ananian