Class OneToManyMap.Entry<From,​To>

  • All Implemented Interfaces:
    java.util.Map.Entry<From,​To>
    Enclosing class:
    OneToManyMap<From,​To>

    public static class OneToManyMap.Entry<From,​To>
    extends java.lang.Object
    implements java.util.Map.Entry<From,​To>
    Helper class to implement the Map.Entry interface to enumerate entries in the map
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object x)
      Compares the specified object with this entry for equality.
      From getKey()
      Answer the key for the entry
      To getValue()
      Answer the value for the entry
      int hashCode()
      Returns the hash code value for this map entry.
      To setValue​(To value)
      Set the value, which writes through to the map.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object x)
        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.
        Specified by:
        equals in interface java.util.Map.Entry<From,​To>
        Overrides:
        equals in class java.lang.Object
        Parameters:
        x - The object to compare against
        Returns:
        True if the given object is equal to this Map.Entry object.
      • getKey

        public From getKey()
        Answer the key for the entry
        Specified by:
        getKey in interface java.util.Map.Entry<From,​To>
        Returns:
        The key object
      • getValue

        public To getValue()
        Answer the value for the entry
        Specified by:
        getValue in interface java.util.Map.Entry<From,​To>
        Returns:
        The value object
      • setValue

        public To setValue​(To value)
                    throws java.lang.UnsupportedOperationException
        Set the value, which writes through to the map. Not implemented.
        Specified by:
        setValue in interface java.util.Map.Entry<From,​To>
        Throws:
        java.lang.UnsupportedOperationException
      • hashCode

        public int 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.
        Specified by:
        hashCode in interface java.util.Map.Entry<From,​To>
        Overrides:
        hashCode in class java.lang.Object