org.omnaest.utils.tuple
Class KeyValue<K,V>

java.lang.Object
  extended by org.omnaest.utils.tuple.KeyValue<K,V>
All Implemented Interfaces:
Serializable, Tuple

public class KeyValue<K,V>
extends Object
implements Tuple

Two arguments Tuple supporting hashCode(), equals(Object) and toString() using the values of the given elements.

Author:
Omnaest
See Also:
Tuple2, Serialized Form

Field Summary
protected  K key
           
protected  V value
           
 
Constructor Summary
KeyValue()
           
KeyValue(KeyValue<K,V> keyValue)
          Creates a new KeyValue instance based on the values of an already existing instance
KeyValue(K key, V value)
           
 
Method Summary
 Map<K,V> asMap()
          Returns a Map containing an entry based on this KeyValue
 boolean equals(Object obj)
           
 K getKey()
          Returns the key
 V getValue()
          Returns the value
 int hashCode()
           
 KeyValue<V,K> newInvertedInstance()
          Returns a new KeyValue instance with inverted first and second value
 void setKey(K key)
          Sets the key
 void setValue(V value)
          Sets the value
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected K key

value

protected V value
Constructor Detail

KeyValue

public KeyValue()
See Also:
KeyValue

KeyValue

public KeyValue(K key,
                V value)
Parameters:
key -
value -
See Also:
KeyValue

KeyValue

public KeyValue(KeyValue<K,V> keyValue)
Creates a new KeyValue instance based on the values of an already existing instance

Parameters:
keyValue -
See Also:
KeyValue
Method Detail

newInvertedInstance

public KeyValue<V,K> newInvertedInstance()
Returns a new KeyValue instance with inverted first and second value

Returns:
KeyValue

getKey

public K getKey()
Returns the key

Returns:

setKey

public void setKey(K key)
Sets the key

Parameters:
key -

getValue

public V getValue()
Returns the value

Returns:

setValue

public void setValue(V value)
Sets the value

Parameters:
value -

asMap

public Map<K,V> asMap()
Returns a Map containing an entry based on this KeyValue

Returns:

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2013. All Rights Reserved.