public class ImmutablePair<S,T> extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable<ImmutablePair<S,T>>, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected S |
first
The first element.
|
protected T |
second
The second element.
|
Constructor and Description |
---|
ImmutablePair(ImmutablePair<S,T> p)
Copy constructor.
|
ImmutablePair(S first,
T second)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected ImmutablePair<S,T> |
clone() |
int |
compareTo(ImmutablePair<S,T> pair) |
boolean |
equals(java.lang.Object obj) |
S |
getFirst()
Returns the first element of the pair.
|
T |
getSecond()
Returns the second element of the pair.
|
int |
hashCode() |
java.lang.String |
toString() |
public ImmutablePair(S first, T second)
public ImmutablePair(ImmutablePair<S,T> p)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
The hash code is based on the hash code of the first and second members.
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
protected ImmutablePair<S,T> clone()
clone
in class java.lang.Object
public int compareTo(ImmutablePair<S,T> pair)
Compare based on first element. Use second element only if first elements are equal. Null entries are sorted to the top.
compareTo
in interface java.lang.Comparable<ImmutablePair<S,T>>