org.eclipse.xtext.xbase.lib
Class Pair<K,V>

java.lang.Object
  extended by org.eclipse.xtext.xbase.lib.Pair<K,V>
Type Parameters:
K - the key-type of the pair.
V - the value-type of the pair.

public final class Pair<K,V>
extends java.lang.Object

An immutable pair of key and value. A pair is considered to be equal to another pair if both the key and the value are equal.

Author:
Sebastian Zarnekow - Initial contribution and API

Constructor Summary
Pair(K k, V v)
          Creates a new instance with the given key and value.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 K getKey()
          Returns the key.
 V getValue()
          Returns the value.
 int hashCode()
           
static
<K,V> Pair<K,V>
of(K k, V v)
          Creates a new instance with the given key and value.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(K k,
            V v)
Creates a new instance with the given key and value.

Parameters:
k - the key. May be null.
v - the value. May be null.
Method Detail

of

public static <K,V> Pair<K,V> of(K k,
                                 V v)
Creates a new instance with the given key and value. May be used instead of the constructor for convenience reasons.

Parameters:
k - the key. May be null.
v - the value. May be null.
Returns:
a newly created pair. Never null.
Since:
2.3

getKey

public K getKey()
Returns the key.

Returns:
the key.

getValue

public V getValue()
Returns the value.

Returns:
the value.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object