KeyValue<K,V>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 | Description |
|---|---|
DefaultKeyValue() |
Constructs a new pair with a null key and null value.
|
DefaultKeyValue(java.util.Map.Entry<? extends K,? extends V> entry) |
Constructs a new pair from the specified
Map.Entry. |
DefaultKeyValue(K key,
V value) |
Constructs a new pair with the specified key and given value.
|
DefaultKeyValue(KeyValue<? extends K,? extends V> pair) |
Constructs a new pair from the specified
KeyValue. |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
equals(java.lang.Object obj) |
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.
|
java.util.Map.Entry<K,V> |
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 nullvalue - the value for the entry, may be nullpublic DefaultKeyValue(KeyValue<? extends K,? extends V> pair)
KeyValue.pair - the pair to copy, must not be nulljava.lang.NullPointerException - if the entry is nullpublic K setKey(K key)
setKey in class AbstractKeyValue<K,V>key - the new keyjava.lang.IllegalArgumentException - if key is this objectpublic V setValue(V value)
setValue in class AbstractKeyValue<K,V>value - the new valuejava.lang.IllegalArgumentException - if value is this objectpublic java.util.Map.Entry<K,V> toMapEntry()
Map.Entry object with key and value from this pair.public boolean equals(java.lang.Object obj)
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.
equals in class java.lang.Objectobj - the object to compare topublic int hashCode()
Implemented per API documentation of Map.Entry.hashCode(),
however subclasses may override this.
hashCode in class java.lang.ObjectCopyright © 2001-2019 - Apache Software Foundation