Class AbstractMapEntry<K,V>

java.lang.Object
net.cscott.jutil.AbstractMapEntry<K,V>
All Implemented Interfaces:
Map.Entry<K,V>
Direct Known Subclasses:
PairMapEntry

public abstract class AbstractMapEntry<K,V> extends Object implements Map.Entry<K,V>
An AbstractMapEntry takes care of most of the grunge work involved in subclassing Map.Entry. For an immutable entry, you need only implement getKey() and getValue(). For a modifiable entry, you must also implement setValue(Object); the default implementation throws an UnsupportedOperationException.
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Compares the specified object with this entry for equality.
    abstract K
    Returns the key corresponding to this entry.
    abstract V
    Returns the value corresponding to this entry.
    int
    Returns the hash code value for this map entry.
    setValue(V value)
    Replaces the value corresponding to this entry with the specified value (optional operation).
    Returns a human-readable representation of this map entry.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AbstractMapEntry

      public AbstractMapEntry()
  • Method Details

    • getKey

      public abstract K getKey()
      Returns the key corresponding to this entry.
      Specified by:
      getKey in interface Map.Entry<K,V>
    • getValue

      public abstract V 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.
      Specified by:
      getValue in interface Map.Entry<K,V>
    • setValue

      public V setValue(V value)
      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).
      Specified by:
      setValue in interface Map.Entry<K,V>
      Returns:
      old value corresponding to entry.
    • toString

      public String toString()
      Returns a human-readable representation of this map entry.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      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.
      Specified by:
      equals in interface Map.Entry<K,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns the hash code value for this map entry.
      Specified by:
      hashCode in interface Map.Entry<K,V>
      Overrides:
      hashCode in class Object