public class DefaultKeyValue extends AbstractKeyValue
KeyValue
pair that does not implement
Map.Entry
.
Note that a DefaultKeyValue
instance may not contain
itself as a key or value.
key, value
Constructor and Description |
---|
DefaultKeyValue()
Constructs a new pair with a null key and null value.
|
DefaultKeyValue(KeyValue pair)
Constructs a new pair from the specified
KeyValue . |
DefaultKeyValue(Map.Entry entry)
Constructs a new pair from the specified
Map.Entry . |
DefaultKeyValue(Object key,
Object value)
Constructs a new pair with the specified key and given value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this
Map.Entry with another Map.Entry . |
int |
hashCode()
Gets a hashCode compatible with the equals method.
|
Object |
setKey(Object key)
Sets the key.
|
Object |
setValue(Object value)
Sets the value.
|
Map.Entry |
toMapEntry()
Returns a new
Map.Entry object with key and value from this pair. |
getKey, getValue, toString
public DefaultKeyValue()
public DefaultKeyValue(Object key, Object value)
key
- the key for the entry, may be nullvalue
- the value for the entry, may be nullpublic DefaultKeyValue(KeyValue pair)
KeyValue
.pair
- the pair to copy, must not be nullNullPointerException
- if the entry is nullpublic DefaultKeyValue(Map.Entry entry)
Map.Entry
.entry
- the entry to copy, must not be nullNullPointerException
- if the entry is nullpublic Object setKey(Object key)
key
- the new keyIllegalArgumentException
- if key is this objectpublic Object setValue(Object value)
value
- the new valueIllegalArgumentException
- if value is this objectpublic Map.Entry toMapEntry()
Map.Entry
object with key and value from this pair.public boolean equals(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.
public int hashCode()
Implemented per API documentation of Map.Entry.hashCode()
,
however subclasses may override this.
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.