Class Pair<V1,V2>

java.lang.Object
org.checkerframework.javacutil.Pair<V1,V2>
Type Parameters:
V1 - the type of the first element of the pair
V2 - the type of the second element of the pair

public class Pair<V1,V2> extends Object
Immutable pair class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final V1
    The first element in the pair.
    final V2
    The second element in the pair.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <V1 extends Cloneable, V2 extends Cloneable>
    Pair<V1,V2>
    cloneElements(Pair<V1,V2> orig)
    Returns a copy of this in which each element is a clone of the corresponding element of this.
    static <V1 extends DeepCopyable<V1>, V2 extends DeepCopyable<V2>>
    Pair<V1,V2>
    deepCopy(Pair<V1,V2> orig)
    Returns a deep copy of this: each element is a deep copy (according to the DeepCopyable interface) of the corresponding element of this.
    static <V1 extends DeepCopyable<V1>, V2>
    Pair<V1,V2>
    deepCopyFirst(Pair<V1,V2> orig)
    Returns a copy, where the first element is deep: the first element is a deep copy (according to the DeepCopyable interface), and the second element is identical to the argument.
    static <V1, V2 extends DeepCopyable<V2>>
    Pair<V1,V2>
    deepCopySecond(Pair<V1,V2> orig)
    Returns a copy, where the second element is deep: the first element is identical to the argument, and the second element is a deep copy (according to the DeepCopyable interface).
    boolean
     
    int
     
    static <V1, V2> Pair<V1,V2>
    of(V1 v1, V2 v2)
     
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • first

      public final V1 first
      The first element in the pair.
    • second

      public final V2 second
      The second element in the pair.
  • Method Details

    • of

      public static <V1, V2> Pair<V1,V2> of(V1 v1, V2 v2)
    • cloneElements

      public static <V1 extends Cloneable, V2 extends Cloneable> Pair<V1,V2> cloneElements(Pair<V1,V2> orig)
      Returns a copy of this in which each element is a clone of the corresponding element of this. clone() may or may not itself make a deep copy of the elements.
      Type Parameters:
      V1 - the type of the first element of the pair
      V2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, with all elements cloned
    • deepCopy

      public static <V1 extends DeepCopyable<V1>, V2 extends DeepCopyable<V2>> Pair<V1,V2> deepCopy(Pair<V1,V2> orig)
      Returns a deep copy of this: each element is a deep copy (according to the DeepCopyable interface) of the corresponding element of this.
      Type Parameters:
      V1 - the type of the first element of the pair
      V2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a deep copy of orig
    • deepCopyFirst

      public static <V1 extends DeepCopyable<V1>, V2> Pair<V1,V2> deepCopyFirst(Pair<V1,V2> orig)
      Returns a copy, where the first element is deep: the first element is a deep copy (according to the DeepCopyable interface), and the second element is identical to the argument.
      Type Parameters:
      V1 - the type of the first element of the pair
      V2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, where the first element is a deep copy
    • deepCopySecond

      public static <V1, V2 extends DeepCopyable<V2>> Pair<V1,V2> deepCopySecond(Pair<V1,V2> orig)
      Returns a copy, where the second element is deep: the first element is identical to the argument, and the second element is a deep copy (according to the DeepCopyable interface).
      Type Parameters:
      V1 - the type of the first element of the pair
      V2 - the type of the second element of the pair
      Parameters:
      orig - a pair
      Returns:
      a copy of orig, where the second element is a deep copy
    • toString

      @SideEffectFree public String toString()
      Overrides:
      toString in class Object
    • hashCode

      @Pure public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object