org.apache.commons.collections.keyvalue

Class TiedMapEntry

public class TiedMapEntry extends Object implements Entry, KeyValue, Serializable

A java.util.Map.Entry Map.Entry tied to a map underneath.

This can be used to enable a map entry to make changes on the underlying map, however this will probably mess up any iterators.

Since: Commons Collections 3.0

Version: $Revision: 405927 $ $Date: 2006-05-12 23:57:03 +0100 (Fri, 12 May 2006) $

Author: Stephen Colebourne

Constructor Summary
TiedMapEntry(Map map, Object key)
Constructs a new entry with the given Map and key.
Method Summary
booleanequals(Object obj)
Compares this Map.Entry with another Map.Entry.
ObjectgetKey()
Gets the key of this entry
ObjectgetValue()
Gets the value of this entry direct from the map.
inthashCode()
Gets a hashCode compatible with the equals method.
ObjectsetValue(Object value)
Sets the value associated with the key direct onto the map.
StringtoString()
Gets a string version of the entry.

Constructor Detail

TiedMapEntry

public TiedMapEntry(Map map, Object key)
Constructs a new entry with the given Map and key.

Parameters: map the map key the key

Method Detail

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

getKey

public Object getKey()
Gets the key of this entry

Returns: the key

getValue

public Object getValue()
Gets the value of this entry direct from the map.

Returns: the 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 associated with the key direct onto the map.

Parameters: value the new value

Returns: the old value

Throws: IllegalArgumentException if the value is set to this map entry

toString

public String toString()
Gets a string version of the entry.

Returns: entry as a string

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