public class DefaultKeyValue<K,V> extends AbstractKeyValue<K ,V>
KeyValue pair that does not implement
Map.Entry.
Note that a DefaultKeyValue instance may not contain itself as a key or value.
| Constructor and Description |
|---|
DefaultKeyValue()
Constructs a new pair with a null key and null value.
|
DefaultKeyValue(KeyValue
Constructs a new pair from the specified
KeyValue.
|
DefaultKeyValue(K key, V value)
Constructs a new pair with the specified key and given value.
|
DefaultKeyValue(Map
Constructs a new pair from the specified
Map.Entry.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object
Compares this
Map.Entry with another
Map.Entry.
|
int |
hashCode()
Gets a hashCode compatible with the equals method.
|
K |
setKey(K key)
Sets the key.
|
V |
setValue(V value)
Sets the value.
|
Map |
toMapEntry()
Returns a new
Map.Entry object with key and value from this pair.
|
getKey, getValue, toStringpublic DefaultKeyValue()
public DefaultKeyValue(K key, V value)
key - the key for the entry, may be null
value - the value for the entry, may be null
public DefaultKeyValue(KeyValue<? extends K ,? extends V> pair)
KeyValue.
pair - the pair to copy, must not be null
NullPointerException - if the entry is null
public DefaultKeyValue(Map.Entry <? extends K ,? extends V> entry)
Map.Entry.
entry - the entry to copy, must not be null
NullPointerException - if the entry is null
public K setKey(K key)
setKey in class
AbstractKeyValue<K,V>
key - the new key
IllegalArgumentException - if key is this object
public V setValue(V value)
setValue in class
AbstractKeyValue<K,V>
value - the new value
IllegalArgumentException - if value is this object
public Map.Entry <K ,V> toMapEntry()
Map.Entry object with key and value from this pair.
public boolean equals(Objectobj)
Map.Entry with another
Map.Entry.
Returns true if the compared object is also a DefaultKeyValue, and its key and value are equal to this object's key and value.
public int hashCode()
Implemented per API documentation of Map, however subclasses may override this.