Class TiedMapEntry
- java.lang.Object
-
- org.apache.commons.collections.keyvalue.TiedMapEntry
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Map.Entry
,KeyValue
public class TiedMapEntry extends java.lang.Object implements java.util.Map.Entry, KeyValue, java.io.Serializable
AMap.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: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
key
The keyprivate java.util.Map
map
The map underlying the entry/iteratorprivate static long
serialVersionUID
Serialization version
-
Constructor Summary
Constructors Constructor Description TiedMapEntry(java.util.Map map, java.lang.Object key)
Constructs a new entry with the given Map and key.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Compares thisMap.Entry
with anotherMap.Entry
.java.lang.Object
getKey()
Gets the key of this entryjava.lang.Object
getValue()
Gets the value of this entry direct from the map.int
hashCode()
Gets a hashCode compatible with the equals method.java.lang.Object
setValue(java.lang.Object value)
Sets the value associated with the key direct onto the map.java.lang.String
toString()
Gets a string version of the entry.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization version- See Also:
- Constant Field Values
-
map
private final java.util.Map map
The map underlying the entry/iterator
-
key
private final java.lang.Object key
The key
-
-
Method Detail
-
getKey
public java.lang.Object getKey()
Gets the key of this entry
-
getValue
public java.lang.Object getValue()
Gets the value of this entry direct from the map.
-
setValue
public java.lang.Object setValue(java.lang.Object value)
Sets the value associated with the key direct onto the map.- Specified by:
setValue
in interfacejava.util.Map.Entry
- Parameters:
value
- the new value- Returns:
- the old value
- Throws:
java.lang.IllegalArgumentException
- if the value is set to this map entry
-
equals
public boolean equals(java.lang.Object obj)
Compares thisMap.Entry
with anotherMap.Entry
.Implemented per API documentation of
Map.Entry.equals(Object)
- Specified by:
equals
in interfacejava.util.Map.Entry
- Overrides:
equals
in classjava.lang.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
Map.Entry.hashCode()
- Specified by:
hashCode
in interfacejava.util.Map.Entry
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a suitable hash code
-
toString
public java.lang.String toString()
Gets a string version of the entry.- Overrides:
toString
in classjava.lang.Object
- Returns:
- entry as a string
-
-