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
,spliterator
methods, any of thetoArray
overloads, 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 theReadOnlyNavigableMap
interface.- 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 K
getKey()
V
getValue()
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 boolean
equals(Object o)
int
hashCode()
-
-
-
Method Detail
-
getKey
-
getValue
-
equals
boolean equals(java.lang.Object o)
Compares the specified object with this entry for equality. ReturnsTRUE
if the given object is also a map entry and the two entries represent the same mapping. More formally, two entriese1
ande2
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 theequals
method works properly across different implementations of theReadOnlyMap.Entry
interface.- Overrides:
equals
in classjava.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 entrye
is 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 Entriese1
ande2
, as required by the general contract ofObject.hashCode
.- Overrides:
hashCode
in 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.Entry
in natural order on key.
The returned comparator is serializable and throwsNullPointerException
when comparing an entry with a null key.- Type Parameters:
K
- theComparable
type of then map keysV
- 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 comparesReadOnlyMap.Entry
in natural order on value.
The returned comparator is serializable and throwsNullPointerException
when comparing an entry with null values.- Type Parameters:
K
- the type of the map keysV
- theComparable
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 comparesReadOnlyMap.Entry
by 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.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 comparesReadOnlyMap.Entry
by 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.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());
-
-