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.Object
2-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 boolean
areBothNull()
boolean
equals(java.lang.Object other)
Checks the two objects for equality by delegating to their respective equals() methods.int
hashCode()
Compute a hash code using the hash codes of the underlying objects.boolean
isEitherNull()
static <P,K>
Pair<P,K>of(P first, K second)
Constructor for a Pair.java.lang.String
toString()
-
-
-
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:
hashCode
in 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:
equals
in 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:
toString
in classjava.lang.Object
-
-