Package blbutil
Class Pair<F,S>
- java.lang.Object
-
- blbutil.Pair<F,S>
-
- Type Parameters:
F- the type of the first object in the pair.S- the type of the second object in the pair.
public final class Pair<F,S> extends java.lang.ObjectClassPairrepresents a pair of ordered objects.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Returnstrueif the specified object is aPairinstance representing the same ordered pair of objects asthis, and returnsfalseotherwise.Ffirst()Returns the first object in the ordered pair of objects.inthashCode()Returns a hash code value for the object.Ssecond()Returns the second object in the ordered pair of objects.java.lang.StringtoString()Returns a string representation ofthis.
-
-
-
Constructor Detail
-
Pair
public Pair(F first, S second)
Constructs aPairinstance representing the specified ordered pair of objects.- Parameters:
first- the first object in the ordered pair of objects.second- the second object in the ordered pair of objects.- Throws:
java.lang.NullPointerException- iffirst==null || second==null.
-
-
Method Detail
-
first
public F first()
Returns the first object in the ordered pair of objects.- Returns:
- the first object in the ordered pair of objects.
-
second
public S second()
Returns the second object in the ordered pair of objects.- Returns:
- the second object in the ordered pair of objects.
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for the object.
-
equals
public boolean equals(java.lang.Object obj)
Returnstrueif the specified object is aPairinstance representing the same ordered pair of objects asthis, and returnsfalseotherwise. Two ordered pairs,p1andp2, are equal ifp1.first().equals(p2.first()) && p1.second().equals(p2.second()).- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to be compared withthisfor equality.- Returns:
trueif the specified object is aPairinstance representing the same ordered pair of objects asthis, and returnsfalseotherwise.
-
toString
public java.lang.String toString()
Returns a string representation ofthis. The exact details of the representation are unspecified and subject to change.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of
this.
-
-