Top Description Fields Constructors Methods
org.apache.commons.collections4.keyvalue

public abstract Class AbstractMapEntryDecorator<K, V>

extends Object
implements Map.Entry<K, V>, KeyValue<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.KeyValue, java.util.Map.Entry
Known Direct Subclasses
org.apache.commons.collections4.map.AbstractInputCheckedMapDecorator.MapEntry, org.apache.commons.collections4.map.UnmodifiableEntrySet.UnmodifiableEntry, org.apache.commons.collections4.bidimap.AbstractDualBidiMap.MapEntry
Type Parameters
<K>
the type of keys
<V>
the type of mapped values
Imports
java.util.Map, org.apache.commons.collections4.KeyValue

Provides a base decorator that allows additional functionality to be added to a Map.Entry.
Since
3.0

Field Summary

Modifier and TypeField and Description
private final Map.Entry<K, V>
entry

The Map.Entry to decorate

Constructor Summary

AccessConstructor and Description
public
AbstractMapEntryDecorator(final Map.Entry<K, V>
the Map.Entry to decorate, must not be null
entry
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
object to be compared for equality with this map entry
object
)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Compares the specified object with this entry for equality.
public K
getKey()

Implements java.util.Map.Entry.getKey, org.apache.commons.collections4.KeyValue.getKey.

Returns the key corresponding to this entry.
protected Map.Entry<K, V>

Returns:

the decorated map
getMapEntry
()

Gets the map being decorated.

public V
getValue()

Implements java.util.Map.Entry.getValue, org.apache.commons.collections4.KeyValue.getValue.

Returns the value corresponding to this entry.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry.
public V
setValue(final V
new value to be stored in this entry
object
)

Implements java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation).
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

entryback to summary
private final Map.Entry<K, V> entry

The Map.Entry to decorate

Constructor Detail

AbstractMapEntryDecoratorback to summary
public AbstractMapEntryDecorator(final Map.Entry<K, V> entry)

Constructor that wraps (not copies).

Parameters
entry:Map.Entry<K, V>

the Map.Entry to decorate, must not be null

Exceptions
NullPointerException:
if the collection is null

Method Detail

equalsback to summary
public boolean equals(final Object object)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Doc from java.util.Map.Entry.equals.

Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries represent the same mapping. More formally, two entries e1 and e2 represent the same mapping if

    (e1.getKey()==null ?
     e2.getKey()==null : e1.getKey().equals(e2.getKey()))  &&
    (e1.getValue()==null ?
     e2.getValue()==null : e1.getValue().equals(e2.getValue()))
This ensures that the equals method works properly across different implementations of the Map.Entry interface.
Parameters
object:Object

object to be compared for equality with this map entry

Returns:boolean

true if the specified object is equal to this map entry

Annotations
@Override
getKeyback to summary
public K getKey()

Implements java.util.Map.Entry.getKey, org.apache.commons.collections4.KeyValue.getKey.

Doc from java.util.Map.Entry.getKey.

Returns the key corresponding to this entry.

Returns:K

the key corresponding to this entry

Annotations
@Override
getMapEntryback to summary
protected Map.Entry<K, V> getMapEntry()

Gets the map being decorated.

Returns:Map.Entry<K, V>

the decorated map

getValueback to summary
public V getValue()

Implements java.util.Map.Entry.getValue, org.apache.commons.collections4.KeyValue.getValue.

Doc from java.util.Map.Entry.getValue.

Returns the value corresponding to this entry. If the mapping has been removed from the backing map (by the iterator's remove operation), the results of this call are undefined.

Returns:V

the value corresponding to this entry

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Doc from java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry. The hash code of a map entry e is defined to be:

    (e.getKey()==null   ? 0 : e.getKey().hashCode()) ^
    (e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures that e1.equals(e2) implies that e1.hashCode()==e2.hashCode() for any two Entries e1 and e2, as required by the general contract of Object.hashCode.
Returns:int

the hash code value for this map entry

Annotations
@Override
setValueback to summary
public V setValue(final V object)

Implements java.util.Map.Entry.setValue.

Doc from java.util.Map.Entry.setValue.

Replaces the value corresponding to this entry with the specified value (optional operation). (Writes through to the map.) The behavior of this call is undefined if the mapping has already been removed from the map (by the iterator's remove operation).

Parameters
object:V

new value to be stored in this entry

Returns:V

old value corresponding to the entry

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override