com.im.commons 5.9

com.im.commons
Class Pair<P,K>

java.lang.Object
  extended by com.im.commons.Pair<P,K>

public final class Pair<P,K>
extends Object

2-tuple utility object. The elements of the 2-tuple might be null.


Field Summary
 P first
           
 K second
           
 
Method Summary
 boolean areBothNull()
           
 boolean equals(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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public final P first

second

public final K second
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 Pair
second - 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 class Object
Returns:
a hashcode of the Pair

equals

public boolean equals(Object other)
Checks the two objects for equality by delegating to their respective equals() methods.

Overrides:
equals in class 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 String toString()
Overrides:
toString in class Object

com.im.commons 5.9