Interface ReadOnlyMap.Entry<K,​V>

    • Method Detail

      • getKey

        🡇     🗕  🗗  🗖
        K getKey()
        Returns the key corresponding to this entry.
        Returns:
        the key corresponding to this entry
      • equals

        🡅  🡇     🗕  🗗  🗖
        boolean equals​(java.lang.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. More formally, two entries e1 and e2 represent the same mapping if

         (e1.getKey()==null
              ? e2.getKey()==null
              : e1.getKey().equals(e2.getKey()))
         &amp;&amp;
         (e1.getValue()==null
              ? e2.getValue()==null
              : e1.getValue().equals(e2.getValue()))
        


        This ensures that the equals method works properly across different implementations of the ReadOnlyMap.Entry interface.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - object to be compared for equality with this map entry
        Returns:
        TRUE if the specified object is equal to this map entry
      • hashCode

        🡅  🡇     🗕  🗗  🗖
        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.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code value for this map entry
        See Also:
        equals(Object)
      • comparingByKey

        🡅  🡇     🗕  🗗  🗖
        static <K extends java.lang.Comparable<? super K>,​V> java.util.Comparator<ReadOnlyMap.Entry<K,​V>> comparingByKey
                    ()
        
        Returns a comparator that compares ReadOnlyMap.Entry in natural order on key.

        The returned comparator is serializable and throws NullPointerException when comparing an entry with a null key.
        Type Parameters:
        K - the Comparable type of then map keys
        V - the type of the map values
        Returns:
        a comparator that compares ReadOnlyMap.Entry in natural order on key.
        Code:
        Exact Method Body:
         return (Comparator<ReadOnlyMap.Entry<K, V>> & Serializable)
             (c1, c2) -> c1.getKey().compareTo(c2.getKey());
        
      • comparingByValue

        🡅  🡇     🗕  🗗  🗖
        static <K,​V extends java.lang.Comparable<? super V>> java.util.Comparator<ReadOnlyMap.Entry<K,​V>> comparingByValue
                    ()
        
        Returns a comparator that compares ReadOnlyMap.Entry in natural order on value.

        The returned comparator is serializable and throws NullPointerException when comparing an entry with null values.
        Type Parameters:
        K - the type of the map keys
        V - the Comparable type of the map values
        Returns:
        a comparator that compares ReadOnlyMap.Entry in natural order on value.
        See Also:
        Comparable
        Code:
        Exact Method Body:
         return (Comparator<ReadOnlyMap.Entry<K, V>> & Serializable)
             (c1, c2) -> c1.getValue().compareTo(c2.getValue());
        
      • comparingByKey

        🡅  🡇     🗕  🗗  🗖
        static <K,​V> java.util.Comparator<ReadOnlyMap.Entry<K,​V>> comparingByKey​
                    (java.util.Comparator<? super K> cmp)
        
        Returns a comparator that compares ReadOnlyMap.Entry by key using the given Comparator.

        The returned comparator is serializable if the specified comparator is also serializable.
        Type Parameters:
        K - the type of the map keys
        V - the type of the map values
        Parameters:
        cmp - the key Comparator
        Returns:
        a comparator that compares ReadOnlyMap.Entry by the key.
        Code:
        Exact Method Body:
         Objects.requireNonNull(cmp);
         return (Comparator<ReadOnlyMap.Entry<K, V>> & Serializable)
             (c1, c2) -> cmp.compare(c1.getKey(), c2.getKey());
        
      • comparingByValue

        🡅     🗕  🗗  🗖
        static <K,​V> java.util.Comparator<ReadOnlyMap.Entry<K,​V>> comparingByValue​
                    (java.util.Comparator<? super V> cmp)
        
        Returns a comparator that compares ReadOnlyMap.Entry by value using the given Comparator.

        The returned comparator is serializable if the specified comparator is also serializable.
        Type Parameters:
        K - the type of the map keys
        V - the type of the map values
        Parameters:
        cmp - the value Comparator
        Returns:
        a comparator that compares ReadOnlyMap.Entry by the value.
        Code:
        Exact Method Body:
         Objects.requireNonNull(cmp);
         return (Comparator<ReadOnlyMap.Entry<K, V>> & Serializable)
             (c1, c2) -> cmp.compare(c1.getValue(), c2.getValue());