Class WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object>

java.lang.Object
org.plumelib.util.WeakIdentityPair<V1,V2>
Type Parameters:
V1 - the type of the pair's first element
V2 - the type of the pair's second element

public class WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> extends Object
Immutable pair class with weakly-held values.

Differs from IPair in the following ways: cannot hold null, holds its elements with weak pointers, clients must use getter methods rather than accessing the fields, and its equals() method uses object equality to compare its elements.

  • Constructor Details

    • WeakIdentityPair

      @Deprecated public WeakIdentityPair(V1 a, V2 b)
      Deprecated.
      Creates a new weakly-held immutable pair. Clients should use of(T1, T2).
      Parameters:
      a - the first element of the pair
      b - the second element of the pair
  • Method Details

    • of

      public static <T1 extends @NonNull Object, T2 extends @NonNull Object> WeakIdentityPair<T1,T2> of(T1 a, T2 b)
      Creates a new weakly-held immutable pair.
      Type Parameters:
      T1 - type of first argument
      T2 - type of second argument
      Parameters:
      a - first argument
      b - second argument
      Returns:
      a pair of the values (a, b)
    • getA

      @SideEffectFree public @Nullable V1 getA(@GuardSatisfied WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> this)
      Return the first element of the pair, or null if it has been garbage-collected.
      Returns:
      the first element of the pail, or null if it has been garbage-collected
    • getB

      @SideEffectFree public @Nullable V2 getB(@GuardSatisfied WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> this)
      Return the second element of the pair, or null if it has been garbage-collected.
      Returns:
      the second element of the pair, or null if it has been garbage-collected
    • equals

      @SideEffectFree public boolean equals(@GuardSatisfied WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> this, @GuardSatisfied @Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      @Pure public int hashCode(@GuardSatisfied WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> this)
      Overrides:
      hashCode in class Object
    • toString

      @SideEffectFree public String toString(@GuardSatisfied WeakIdentityPair<V1 extends @NonNull Object,V2 extends @NonNull Object> this)
      Overrides:
      toString in class Object