Modifier and Type | Method and Description |
---|---|
static <K extends Comparable<? super K>,V> |
comparingByKey()
Returns a comparator that compares
Map.Entry in natural order
on key. |
static <K,V> Comparator<Map.Entry<K,V>> |
comparingByKey(Comparator<? super K> cmp)
Returns a comparator that compares
Map.Entry by key using the
given Comparator . |
static <K,V extends Comparable<? super V>> |
comparingByValue()
Returns a comparator that compares
Map.Entry in natural order
on value. |
static <K,V> Comparator<Map.Entry<K,V>> |
comparingByValue(Comparator<? super V> cmp)
Returns a comparator that compares
Map.Entry by value using
the given Comparator . |
static <K,V> Map.Entry<K,V> |
copyOf(Map.Entry<? extends K,? extends V> e)
Returns a copy of the given
Map.Entry . |
public static <K extends Comparable<? super K>,V> Comparator<Map.Entry<K,V>> comparingByKey()
Map.Entry
in natural order
on key.
The returned comparator is serializable and throws
NullPointerException
when comparing an entry with a null key.
K
- the Comparable
type of then map keysV
- the type of the map valuesMap.Entry
in natural order
on key.Comparable
public static <K,V extends Comparable<? super V>> Comparator<Map.Entry<K,V>> comparingByValue()
Map.Entry
in natural order
on value.
The returned comparator is serializable and throws
NullPointerException
when comparing an entry with null
values.
K
- the type of the map keysV
- the Comparable
type of the map valuesMap.Entry
in natural order
on value.Comparable
public static <K,V> Comparator<Map.Entry<K,V>> comparingByKey(Comparator<? super K> cmp)
Map.Entry
by key using the
given Comparator
.
The returned comparator is serializable if the specified comparator is also serializable.
K
- the type of the map keysV
- the type of the map valuescmp
- the key Comparator
Map.Entry
by the key.public static <K,V> Comparator<Map.Entry<K,V>> comparingByValue(Comparator<? super V> cmp)
Map.Entry
by value using
the given Comparator
.
The returned comparator is serializable if the specified comparator is also serializable.
K
- the type of the map keysV
- the type of the map valuescmp
- the value Comparator
Map.Entry
by the value.public static <K,V> Map.Entry<K,V> copyOf(Map.Entry<? extends K,? extends V> e)
Map.Entry
. The returned instance is not
associated with any map. The returned instance has the same characteristics
as instances returned by the Maps::entry
method.
API Note:
An instance obtained from a map's entry-set view has a connection to that map.
The copyOf
method may be used to create a Map.Entry
instance,
containing the same key and value, that is independent of any map.
Implementation Note:
If the given entry was obtained from a call to copyOf
or Maps::entry
,
calling copyOf
will generally not create another copy.
K
- the type of the keyV
- the type of the valuee
- the entry to be copiedNullPointerException
- if e is null or if either of its key or value is nullCopyright © 2021. All rights reserved.