Package com.im.commons
Class Pair<P,K>
- java.lang.Object
-
- com.im.commons.Pair<P,K>
-
public final class Pair<P,K> extends java.lang.Object2-tuple utility object. The elements of the 2-tuple might benull.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanareBothNull()booleanequals(java.lang.Object other)Checks the two objects for equality by delegating to their respective equals() methods.inthashCode()Compute a hash code using the hash codes of the underlying objects.booleanisEitherNull()static <P,K>
Pair<P,K>of(P first, K second)Constructor for a Pair.java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static <P,K> Pair<P,K> of(P first, K second)
Constructor for a Pair.- Parameters:
first- the first object in the Pairsecond- the second object in the pair
-
areBothNull
public boolean areBothNull()
- Returns:
- whether both elements of this 2-tuple are
null.
-
isEitherNull
public boolean isEitherNull()
- Returns:
- whether any of the two elements of this 2-tuple are
null.
-
hashCode
public int hashCode()
Compute a hash code using the hash codes of the underlying objects.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hashcode of the Pair
-
equals
public boolean equals(java.lang.Object other)
Checks the two objects for equality by delegating to their respective equals() methods.- Overrides:
equalsin classjava.lang.Object- Parameters:
other- the Pair to which this one is to be checked for equality- Returns:
- true if the underlying objects of the Pair are both considered equals()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-