Class Pair<K,V>

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

@GwtCompatible public final class Pair<K,V> extends Object implements Serializable
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
See Also:
  • Constructor Details

    • Pair

      @Pure 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 Details

    • of

      @Pure 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

      @Pure public K getKey()
      Returns the key.
      Returns:
      the key.
    • getValue

      @Pure public V getValue()
      Returns the value.
      Returns:
      the value.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object