Package Torello.Java.ReadOnly
Interface ReadOnlyMap.Entry<K,V>
-
- Type Parameters:
K- the type of the keyV- the type of the value
- Enclosing interface:
- ReadOnlyMap<K,V>
public static interface ReadOnlyMap.Entry<K,V>
A map entry (key-value pair).
An Entry may also be obtained from a map's entry-set view by other means, for example, using theparallelStream,stream,spliteratormethods, any of thetoArrayoverloads, or by copying the entry-set view into another collection.
In addition, an Entry may be obtained directly from a map, for example via calls to methods directly on theReadOnlyNavigableMapinterface.- See Also:
ReadOnlyMap.entrySet()
Hi-Lited Source-Code:- View Here: Torello/Java/ReadOnly/ReadOnlyMap.java
- Open New Browser-Tab: Torello/Java/ReadOnly/ReadOnlyMap.java
File Size: 6,307 Bytes Line Count: 156 '\n' Characters Found
-
-
Method Summary
Primary Methods Modifier and Type Method KgetKey()VgetValue()Static Comparator Methods Modifier and Type Method static <K extends Comparable<? super K>,
V>
Comparator<ReadOnlyMap.Entry<K,
V>>comparingByKey()static <K,
V>
Comparator<ReadOnlyMap.Entry<K,
V>>comparingByKey(Comparator<? super K> cmp)static <K,
V extends Comparable<? super V>>
Comparator<ReadOnlyMap.Entry<K,
V>>comparingByValue()static <K,
V>
Comparator<ReadOnlyMap.Entry<K,
V>>comparingByValue(Comparator<? super V> cmp)Methods: class java.lang.Object Modifier and Type Method booleanequals(Object o)inthashCode()
-
-
-
Method Detail
-
getKey
-
getValue
-
equals
boolean equals(java.lang.Object o)
Compares the specified object with this entry for equality. ReturnsTRUEif the given object is also a map entry and the two entries represent the same mapping. More formally, two entriese1ande2represent 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 theequalsmethod works properly across different implementations of theReadOnlyMap.Entryinterface.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- object to be compared for equality with this map entry- Returns:
TRUEif 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 entryeis defined to be:
(e.getKey()==null ? 0 : e.getKey().hashCode()) ^ (e.getValue()==null ? 0 : e.getValue().hashCode())
This ensures thate1.equals(e2)implies thate1.hashCode()==e2.hashCode()for any two Entriese1ande2, as required by the general contract ofObject.hashCode.- Overrides:
hashCodein classjava.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 comparesReadOnlyMap.Entryin natural order on key.
The returned comparator is serializable and throwsNullPointerExceptionwhen comparing an entry with a null key.- Type Parameters:
K- theComparabletype of then map keysV- the type of the map values- Returns:
- a comparator that compares
ReadOnlyMap.Entryin 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 comparesReadOnlyMap.Entryin natural order on value.
The returned comparator is serializable and throwsNullPointerExceptionwhen comparing an entry with null values.- Type Parameters:
K- the type of the map keysV- theComparabletype of the map values- Returns:
- a comparator that compares
ReadOnlyMap.Entryin 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 comparesReadOnlyMap.Entryby key using the givenComparator.
The returned comparator is serializable if the specified comparator is also serializable.- Type Parameters:
K- the type of the map keysV- the type of the map values- Parameters:
cmp- the keyComparator- Returns:
- a comparator that compares
ReadOnlyMap.Entryby 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 comparesReadOnlyMap.Entryby value using the givenComparator.
The returned comparator is serializable if the specified comparator is also serializable.- Type Parameters:
K- the type of the map keysV- the type of the map values- Parameters:
cmp- the valueComparator- Returns:
- a comparator that compares
ReadOnlyMap.Entryby the value. - Code:
- Exact Method Body:
Objects.requireNonNull(cmp); return (Comparator<ReadOnlyMap.Entry<K, V>> & Serializable) (c1, c2) -> cmp.compare(c1.getValue(), c2.getValue());
-
-