edu.mit.csail.sdg.alloy4
Class Pair<A,B>

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4.Pair<A,B>
All Implemented Interfaces:
java.io.Serializable

public final class Pair<A,B>
extends java.lang.Object
implements java.io.Serializable

Immutable; stores a pair of object references; Pair.equals() compares by calling equals() on both components.

Thread Safety: Safe (since objects of this class are immutable).

See Also:
Serialized Form

Field Summary
 A a
          The first half of the pair.
 B b
          The second half of the pair.
 
Constructor Summary
Pair(A a, B b)
          Constructs a new Pair object (a,b).
 
Method Summary
 boolean equals(java.lang.Object that)
          Pairs (a1, b1) and (a2, b2) are equal iff (a1==null ? a2==null : a1.equals(a2)) and (b1==null ? b2==null : b1.equals(b2))
 int hashCode()
          Returns a hashcode based on (a==null?0:a.hashCode()) and (b==null?0:b.hashCode()).
 java.lang.String toString()
          If "a" and "b" are both String, concatename them with a space; if only one is, return it; else call toString() on them.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

a

public final A a
The first half of the pair.


b

public final B b
The second half of the pair.

Constructor Detail

Pair

public Pair(A a,
            B b)
Constructs a new Pair object (a,b).

Method Detail

toString

public java.lang.String toString()
If "a" and "b" are both String, concatename them with a space; if only one is, return it; else call toString() on them.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Returns a hashcode based on (a==null?0:a.hashCode()) and (b==null?0:b.hashCode()).

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object that)
Pairs (a1, b1) and (a2, b2) are equal iff (a1==null ? a2==null : a1.equals(a2)) and (b1==null ? b2==null : b1.equals(b2))

Overrides:
equals in class java.lang.Object