fabric.common.util
Class AbstractLongKeyMap.SimpleEntry<V>

java.lang.Object
  extended by fabric.common.util.AbstractLongKeyMap.SimpleEntry<V>
All Implemented Interfaces:
LongKeyMap.Entry<V>, java.io.Serializable
Enclosing class:
AbstractLongKeyMap<V>

public static class AbstractLongKeyMap.SimpleEntry<V>
extends java.lang.Object
implements LongKeyMap.Entry<V>, java.io.Serializable

A class which implements Map.Entry. It is shared by HashMap, TreeMap, Hashtable, and Collections. It is not specified by the JDK, but makes life much easier.

Since:
1.6
Author:
Jon Zeppieri, Eric Blake (ebb9@email.byu.edu)
See Also:
Serialized Form

Constructor Summary
AbstractLongKeyMap.SimpleEntry(LongKeyMap.Entry<? extends V> entry)
           
AbstractLongKeyMap.SimpleEntry(long newKey, V newValue)
          Basic constructor initializes the fields.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified object with this entry.
 long getKey()
          Get the key corresponding to this entry.
 V getValue()
          Get the value corresponding to this entry.
 int hashCode()
          Returns the hash code of the entry.
 V setValue(V newVal)
          Replaces the value with the specified object.
 java.lang.String toString()
          This provides a string representation of the entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractLongKeyMap.SimpleEntry

public AbstractLongKeyMap.SimpleEntry(long newKey,
                                      V newValue)
Basic constructor initializes the fields.

Parameters:
newKey - the key
newValue - the value

AbstractLongKeyMap.SimpleEntry

public AbstractLongKeyMap.SimpleEntry(LongKeyMap.Entry<? extends V> entry)
Method Detail

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this entry. Returns true only if the object is a mapping of identical key and value. In other words, this must be:
(o instanceof Map.Entry)
       && (getKey() == null ? ((HashMap) o).getKey() == null
           : getKey().equals(((HashMap) o).getKey()))
       && (getValue() == null ? ((HashMap) o).getValue() == null
           : getValue().equals(((HashMap) o).getValue()))

Specified by:
equals in interface LongKeyMap.Entry<V>
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare
Returns:
true if it is equal

getKey

public long getKey()
Get the key corresponding to this entry.

Specified by:
getKey in interface LongKeyMap.Entry<V>
Returns:
the key

getValue

public V getValue()
Get the value corresponding to this entry. If you already called Iterator.remove(), the behavior undefined, but in this case it works.

Specified by:
getValue in interface LongKeyMap.Entry<V>
Returns:
the value

hashCode

public int hashCode()
Returns the hash code of the entry. This is defined as the exclusive-or of the hashcodes of the key and value (using 0 for null). In other words, this must be:
(getKey() == null ? 0 : getKey().hashCode())
       ^ (getValue() == null ? 0 : getValue().hashCode())

Specified by:
hashCode in interface LongKeyMap.Entry<V>
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code

setValue

public V setValue(V newVal)
Replaces the value with the specified object. This writes through to the map, unless you have already called Iterator.remove(). It may be overridden to restrict a null value.

Specified by:
setValue in interface LongKeyMap.Entry<V>
Parameters:
newVal - the new value to store
Returns:
the old value
Throws:
java.lang.NullPointerException - if the map forbids null values.
java.lang.UnsupportedOperationException - if the map doesn't support put().
java.lang.ClassCastException - if the value is of a type unsupported by the map.
java.lang.IllegalArgumentException - if something else about this value prevents it being stored in the map.

toString

public java.lang.String toString()
This provides a string representation of the entry. It is of the form "key=value", where string concatenation is used on key and value.

Overrides:
toString in class java.lang.Object
Returns:
the string representation