Added in API level 9

SimpleImmutableEntry

open class SimpleImmutableEntry<K : Any!, V : Any!> : MutableEntry<K, V>, Serializable
kotlin.Any
   ↳ java.util.AbstractMap.SimpleImmutableEntry

An unmodifiable Entry maintaining a key and a value. This class does not support the setValue method. Instances of this class are not associated with any map nor with any map's entry-set view.

Summary

Public constructors
SimpleImmutableEntry(entry: MutableEntry<out K, out V>)

Creates an entry representing the same mapping as the specified entry.

SimpleImmutableEntry(key: K, value: V)

Creates an entry representing a mapping from the specified key to the specified value.

Public methods
open Boolean
equals(other: Any?)

Compares the specified object with this entry for equality.

open Int

Returns the hash code value for this map entry.

open V
setValue(newValue: V)

Replaces the value corresponding to this entry with the specified value (optional operation).

open String

Returns a String representation of this map entry.

Properties
open K

Returns the key corresponding to this entry.

open V

Returns the value corresponding to this entry.

Public constructors

SimpleImmutableEntry

Added in API level 9
SimpleImmutableEntry(entry: MutableEntry<out K, out V>)

Creates an entry representing the same mapping as the specified entry.

Parameters
entry MutableEntry<out K, out V>: the entry to copy

SimpleImmutableEntry

Added in API level 9
SimpleImmutableEntry(
    key: K,
    value: V)

Creates an entry representing a mapping from the specified key to the specified value.

Parameters
key K: the key represented by this entry
value V: the value represented by this entry

Public methods

equals

Added in API level 9
open fun equals(other: Any?): Boolean

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()))
    &&
    (e1.getValue()==null ?
     e2.getValue()==null :
     e1.getValue().equals(e2.getValue()))
This ensures that the equals method works properly across different implementations of the Map.Entry interface.

Parameters
obj the reference object with which to compare.
o object to be compared for equality with this map entry
Return
Boolean true if the specified object is equal to this map entry

See Also

hashCode

Added in API level 9
open fun hashCode(): Int

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.

Return
Int the hash code value for this map entry

See Also

setValue

Added in API level 9
open fun setValue(newValue: V): V

Replaces the value corresponding to this entry with the specified value (optional operation). This implementation simply throws UnsupportedOperationException, as this class implements an unmodifiable map entry.

Parameters
value new value to be stored in this entry
Return
V (Does not return)
Exceptions
java.lang.UnsupportedOperationException always
java.lang.ClassCastException if the class of the specified value prevents it from being stored in the backing map
java.lang.NullPointerException if the backing map does not permit null values, and the specified value is null
java.lang.IllegalArgumentException if some property of this value prevents it from being stored in the backing map
java.lang.IllegalStateException implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.

toString

Added in API level 9
open fun toString(): String

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.

Return
String a String representation of this map entry

Properties

key

Added in API level 9
open val key: K

Returns the key corresponding to this entry.

Return
K the key corresponding to this entry
Exceptions
java.lang.IllegalStateException implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.

value

Added in API level 9
open val value: V

Returns the value corresponding to this entry.

Return
V the value corresponding to this entry
Exceptions
java.lang.IllegalStateException implementations may, but are not required to, throw this exception if the entry has been removed from the backing map.