Constructor and Description |
---|
DefaultKeyValue(KeyValue<K,V> pair)
Constructs a new pair from the specified
KeyValue . |
DefaultKeyValue(KeyValue<K,V> pair,
boolean compareByKeyOnly)
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(K key,
V value,
boolean compareByKeyOnly)
Constructs a new pair with the specified key and given value.
|
DefaultKeyValue(Map.Entry<K,V> entry)
Constructs a new pair from the specified
Map.Entry . |
DefaultKeyValue(Map.Entry<K,V> entry,
boolean compareByKeyOnly)
Constructs a new pair from the specified
Map.Entry . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this
KeyValue with another KeyValue . |
K |
getKey()
Gets the key from the pair.
|
V |
getValue()
Gets the value from the pair.
|
int |
hashCode()
Gets a hashCode compatible with the equals method.
|
K |
setKey(K key)
Sets the key.
|
V |
setValue(V value)
Sets the value.
|
public DefaultKeyValue(K key, V value)
key
- the key for the entry, may be nullvalue
- the value for the entry, may be nullpublic DefaultKeyValue(K key, V value, boolean compareByKeyOnly)
key
- the key for the entry, may be nullvalue
- the value for the entry, may be nullcompareByKeyOnly
- flag if equals() depends on key onlypublic DefaultKeyValue(KeyValue<K,V> pair)
KeyValue
.pair
- the pair to copy, must not be nullNullPointerException
- if the entry is nullpublic DefaultKeyValue(KeyValue<K,V> pair, boolean compareByKeyOnly)
KeyValue
.pair
- the pair to copy, must not be nullcompareByKeyOnly
- flag if equals() depends on key onlyNullPointerException
- if the entry is nullpublic DefaultKeyValue(Map.Entry<K,V> entry)
Map.Entry
.entry
- the entry to copy, must not be nullNullPointerException
- if the entry is nullpublic DefaultKeyValue(Map.Entry<K,V> entry, boolean compareByKeyOnly)
Map.Entry
.entry
- the entry to copy, must not be nullcompareByKeyOnly
- flag if equals() depends on key onlyNullPointerException
- if the entry is nullpublic K getKey()
public V getValue()
public K setKey(K key)
key
- the new keyIllegalArgumentException
- if key is this objectpublic V setValue(V value)
value
- the new valueIllegalArgumentException
- if value is this objectpublic boolean equals(Object obj)
KeyValue
with another KeyValue
.
Returns true if the compared object is also a DefaultKeyValue
,
and its key and value are equal to this object's key and value.
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.