KeyType
- The type of the key.ValueType
- The type of the value.public class DefaultKeyValuePair<KeyType,ValueType> extends AbstractCloneableSerializable implements KeyValuePair<KeyType,ValueType>
KeyValuePair
interface.Modifier and Type | Field and Description |
---|---|
protected KeyType |
key
The key part in the pair, which is the first element.
|
protected ValueType |
value
The value part in the pair, which is the second element.
|
Constructor and Description |
---|
DefaultKeyValuePair()
Creates a new, empty
DefaultKeyValuePair . |
DefaultKeyValuePair(KeyType key,
ValueType value)
Creates a new
DefaultKeyValuePair from the given key and value. |
DefaultKeyValuePair(KeyValuePair<? extends KeyType,? extends ValueType> other)
Creates a new
DefaultKeyValuePair as a shallow copy of the
given key-value pair. |
Modifier and Type | Method and Description |
---|---|
static <KeyType,ValueType> |
create()
Convenience method to create a new, empty
DefaultKeyValuePair . |
static <KeyType,ValueType> |
create(KeyType key,
ValueType value)
Convenience method to create a new
DefaultKeyValuePair from the
given key and value. |
boolean |
equals(java.lang.Object o) |
KeyType |
getFirst()
Gets the first object.
|
KeyType |
getKey()
Gets the key part of the key-value pair.
|
ValueType |
getSecond()
Gets the second object.
|
ValueType |
getValue()
Gets the value part of the key-value pair.
|
int |
hashCode() |
void |
setKey(KeyType key)
Sets the key element of the pair.
|
void |
setValue(ValueType value)
Sets the value element of the pair.
|
java.lang.String |
toString() |
clone
protected KeyType key
protected ValueType value
public DefaultKeyValuePair()
DefaultKeyValuePair
.public DefaultKeyValuePair(KeyType key, ValueType value)
DefaultKeyValuePair
from the given key and value.key
- The key.value
- The value.public DefaultKeyValuePair(KeyValuePair<? extends KeyType,? extends ValueType> other)
DefaultKeyValuePair
as a shallow copy of the
given key-value pair.other
- The key-value pair to copy.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public ValueType getSecond()
Pair
public KeyType getKey()
KeyValuePair
getKey
in interface KeyValuePair<KeyType,ValueType>
public void setKey(KeyType key)
key
- The key.public ValueType getValue()
KeyValuePair
getValue
in interface KeyValuePair<KeyType,ValueType>
public void setValue(ValueType value)
value
- The value.public static <KeyType,ValueType> DefaultKeyValuePair<KeyType,ValueType> create()
DefaultKeyValuePair
.KeyType
- The type of the key.ValueType
- The type of the value.public static <KeyType,ValueType> DefaultKeyValuePair<KeyType,ValueType> create(KeyType key, ValueType value)
DefaultKeyValuePair
from the
given key and value.KeyType
- The type of the key.ValueType
- The type of the value.key
- The key.value
- The value.