Top Description Fields Constructors Methods
java.util

pack-priv final Class KeyValueHolder<K, V>

extends Object
implements Map.Entry<K, V>
Class Inheritance
All Implemented Interfaces
java.util.Map.Entry
Annotations
@ValueBased
Type Parameters
<K>
the key type
<V>
the value type
Imports
jdk.internal.vm.annotation.Stable

An immutable container for a key and a value, suitable for use in creating and populating Map instances.

This is a value-based class; programmers should treat instances that are equal as interchangeable and should not use instances for synchronization, or unpredictable behavior may occur. For example, in a future release, synchronization may fail.

API Note

This class is not public. Instances can be created using the Map.entry(k, v) factory method, which is public.

This class differs from AbstractMap.SimpleImmutableEntry in the following ways: it is not serializable, it is final, and its key and value must be non-null.

Since
9
See Also
Map.ofEntries()

Field Summary

Modifier and TypeField and Description
pack-priv final K
pack-priv final V

Constructor Summary

AccessConstructor and Description
pack-priv
KeyValueHolder(K k, V v)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
object to be compared for equality with this map entry
o
)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Compares the specified object with this entry for equality.
public K

Returns:

the key
getKey
()

Implements java.util.Map.Entry.getKey.

Gets the key from this holder.
public V

Returns:

the value
getValue
()

Implements java.util.Map.Entry.getValue.

Gets the value from this holder.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry.
public V

Returns:

never returns normally
setValue
(V
ignored
value
)

Implements java.util.Map.Entry.setValue.

Throws UnsupportedOperationException.
public String

Returns:

a String representation of this map entry
toString
()

Overrides java.lang.Object.toString.

Returns a String representation of this map entry.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

keyback to summary
pack-priv final K key
Annotations
@Stable
valueback to summary
pack-priv final V value
Annotations
@Stable

Constructor Detail

KeyValueHolderback to summary
pack-priv KeyValueHolder(K k, V v)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements java.util.Map.Entry.equals.

Compares the specified object with this entry for equality. Returns true if the given object is also a map entry and the two entries' keys and values are equal. Note that key and value are non-null, so equals() can be called safely on them.

Parameters
o:Object

Doc from java.util.Map.Entry.equals.

object to be compared for equality with this map entry

Returns:boolean

Doc from java.util.Map.Entry.equals.

true if the specified object is equal to this map entry

Annotations
@Override
getKeyback to summary
public K getKey()

Implements java.util.Map.Entry.getKey.

Gets the key from this holder.

Returns:K

the key

Annotations
@Override
getValueback to summary
public V getValue()

Implements java.util.Map.Entry.getValue.

Gets the value from this holder.

Returns:V

the value

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.Entry.hashCode.

Returns the hash code value for this map entry. The hash code is key.hashCode() ^ value.hashCode(). Note that key and value are non-null, so hashCode() can be called safely on them.

Returns:int

Doc from java.util.Map.Entry.hashCode.

the hash code value for this map entry

Annotations
@Override
setValueback to summary
public V setValue(V value)

Implements java.util.Map.Entry.setValue.

Throws UnsupportedOperationException.

Parameters
value:V

ignored

Returns:V

never returns normally

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a String representation of this map entry. This implementation returns the string representation of this entry's key followed by the equals character ("=") followed by the string representation of this entry's value.

Returns:String

a String representation of this map entry

Annotations
@Override