JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.util
Class Pair<T1,T2>

java.lang.Object
  extended by net.sf.japi.util.Pair<T1,T2>

public class Pair<T1,T2>
extends Object

Lightweight class for data pairs. The hashcode of a pair is the combined hashcode of its values.

Author:
Christian Hujer

Constructor Summary
Pair(T1 first, T2 second)
          Create a Pair.
 
Method Summary
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 T1 getFirst()
          Get first member of this pair.
 T2 getSecond()
          Get second member of this pair.
 int hashCode()
          Returns a hash code value for the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pair

public Pair(T1 first,
            T2 second)
Create a Pair.

Parameters:
first - First data element
second - Second data element
Method Detail

getFirst

public T1 getFirst()
Get first member of this pair.

Returns:
first member of this pair

getSecond

public T2 getSecond()
Get second member of this pair.

Returns:
second member of this pair

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright