⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections

Class DefaultMapEntry

java.lang.Object
|
+--org.apache.commons.collections.DefaultMapEntry

All Implemented Interfaces:
Map.Entry, KeyValue


public class DefaultMapEntry
extends java.lang.Object
implements Map.Entry, KeyValue

A default implementation of java.util.Map.Entry
Since:
Commons Collections 1.0
Authors:
James Strachan
Michael A. Smith
Neil O'Toole
Stephen Colebourne

Constructor Summary

DefaultMapEntry()

Constructs a new DefaultMapEntry with a null key and null value.

DefaultMapEntry(Map.Entry entry)

Constructs a new DefaultMapEntry with the given key and given value.

DefaultMapEntry(Object key, Object value)

Constructs a new DefaultMapEntry with the given key and given value.

Method Summary

boolean

equals(Object obj)

Compares this Map Entry with another Map Entry.

Object

getKey()

Gets the key from the Map Entry.

Object

getValue()

Gets the value from the Map Entry.

int

hashCode()

Gets a hashCode compatible with the equals method.

void

setKey(Object key)

Sets the key stored in this Map Entry.

Object

setValue(Object value)

Sets the value stored in this Map Entry.

String

toString()

Written to match the output of the Map.Entry's used in a java.util.HashMap.

Constructor Details

DefaultMapEntry

public DefaultMapEntry()

Constructs a new DefaultMapEntry with a null key and null value.


DefaultMapEntry

public DefaultMapEntry(Map.Entry entry)

Constructs a new DefaultMapEntry with the given key and given value.

Parameters:
entry - the entry to copy, must not be null
Throws:
- if the entry is null

DefaultMapEntry

public DefaultMapEntry(Object key, Object value)

Constructs a new DefaultMapEntry 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

getKey

public Object getKey()

Gets the key from the Map Entry.

Returns:
the key

getValue

public Object getValue()

Gets the value from the Map Entry.

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

setKey

public void setKey(Object key)

Sets the key stored in this Map Entry.

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

Parameters:
key - the new key

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

toString

public String toString()

Written to match the output of the Map.Entry's used in a java.util.HashMap.

Since:
3.0