public class

DefaultMapEntry

extends Object
implements Map.Entry<K, V> KeyValue
java.lang.Object
   ↳ org.apache.commons.collections.DefaultMapEntry

This class is deprecated.
Use the version in the keyvalue subpackage. Will be removed in v4.0

Class Overview

A default implementation of java.util.Map.Entry

Summary

Public Constructors
DefaultMapEntry()
Constructs a new DefaultMapEntry with a null key and null value.
DefaultMapEntry(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.
Public Methods
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 HashMap.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Map.Entry
From interface org.apache.commons.collections.KeyValue

Public Constructors

public DefaultMapEntry ()

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

public DefaultMapEntry (Entry entry)

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

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

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

Public Methods

public boolean equals (Object obj)

Compares this Map Entry with another Map Entry.

Implemented per API documentation of equals(Object)

Parameters
obj the object to compare to
Returns
  • true if equal key and value

public Object getKey ()

Gets the key from the Map Entry.

Returns
  • the key

public Object getValue ()

Gets the value from the Map Entry.

Returns
  • the value

public int hashCode ()

Gets a hashCode compatible with the equals method.

Implemented per API documentation of hashCode()

Returns
  • a suitable hash code

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

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

public String toString ()

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