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.Object
ClassPair
represents a pair of ordered objects.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Returnstrue
if the specified object is aPair
instance representing the same ordered pair of objects asthis
, and returnsfalse
otherwise.F
first()
Returns the first object in the ordered pair of objects.int
hashCode()
Returns a hash code value for the object.S
second()
Returns the second object in the ordered pair of objects.java.lang.String
toString()
Returns a string representation ofthis
.
-
-
-
Constructor Detail
-
Pair
public Pair(F first, S second)
Constructs aPair
instance 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:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for the object.
-
equals
public boolean equals(java.lang.Object obj)
Returnstrue
if the specified object is aPair
instance representing the same ordered pair of objects asthis
, and returnsfalse
otherwise. Two ordered pairs,p1
andp2
, are equal ifp1.first().equals(p2.first()) && p1.second().equals(p2.second())
.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to be compared withthis
for equality.- Returns:
true
if the specified object is aPair
instance representing the same ordered pair of objects asthis
, and returnsfalse
otherwise.
-
toString
public java.lang.String toString()
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of
this
.
-
-