org.apache.commons.collections.keyvalue

Class AbstractMapEntry

Implemented Interfaces:
Map.Entry, KeyValue
Known Direct Subclasses:
BeanMap.MyMapEntry, DefaultMapEntry, UnmodifiableMapEntry

public abstract class AbstractMapEntry
extends AbstractKeyValue
implements Map.Entry

Abstract Pair class to assist with creating correct Map Entry implementations.

Version:
$Revision: 1.4 $ $Date: 2004/02/18 01:00:08 $

Authors:
James Strachan
Michael A. Smith
Neil O'Toole
Stephen Colebourne

Since:
Commons Collections 3.0

Field Summary

Fields inherited from class org.apache.commons.collections.keyvalue.AbstractKeyValue

key, value

Constructor Summary

AbstractMapEntry(Object key, Object value)
Constructs a new entry with the given key and given value.

Method Summary

boolean
equals(Object obj)
Compares this Map Entry with another Map Entry.
int
hashCode()
Gets a hashCode compatible with the equals method.
Object
setValue(Object value)
Sets the value stored in this Map Entry.

Methods inherited from class org.apache.commons.collections.keyvalue.AbstractKeyValue

getKey, getValue, toString

Constructor Details

AbstractMapEntry

protected AbstractMapEntry(Object key,
                           Object value)
Constructs a new entry with the given key and given value.

Parameters:
key - the key for the entry, may be null
value - the value for the entry, may be null

Method Details

equals

public boolean equals(Object obj)
Compares this Map Entry with another Map Entry.

Implemented per API documentation of java.util.Map.Entry.equals(Object)

Parameters:
obj - the object to compare to

Returns:
true if equal key and value


hashCode

public int hashCode()
Gets a hashCode compatible with the equals method.

Implemented per API documentation of java.util.Map.Entry.hashCode()

Returns:
a suitable hash code


setValue

public Object setValue(Object value)
Sets the value stored in this Map Entry.

This Map Entry is not connected to a Map, so only the local data is changed.

Parameters:
value - the new value

Returns:
the previous value


Copyright © 2001-2005 Apache Software Foundation. All Rights Reserved.