y.util
Class Tuple

java.lang.Object
  |
  +--y.util.Tuple
All Implemented Interfaces:
Serializable

public final class Tuple
extends Object
implements Serializable

This class represents an ordered 2-Tuple that is consistent with equals() and hashCode(). Therefor it can safely be used within Hashtables, HashSets, HashMaps and the like. Using the static create methods, it is possible to build 3,4,5-Tuples recursively out of multiple 2-Tuples.

See Also:
Serialized Form

Field Summary
 Object o1
          The first element of the Tuple
 Object o2
          The second element of the Tuple
 
Constructor Summary
Tuple(Object o1, Object o2)
          Constructs a 2-Tuple using the two given Objects
 
Method Summary
static Object create(Object o1, Object o2)
          Factory method to create a 2-Tuple
static Object create(Object o1, Object o2, Object o3)
          Factory method to create a 3-Tuple
static Object create(Object o1, Object o2, Object o3, Object o4)
          Factory method to create a 4-Tuple
static Object create(Object o1, Object o2, Object o3, Object o4, Object o5)
          Factory method to create a 5-Tuple
 boolean equals(Object o)
          Determines if the given Tuple equals another Tuple.
 int hashCode()
          Generates a hashCode using the two tuple elements.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

o1

public final Object o1
The first element of the Tuple


o2

public final Object o2
The second element of the Tuple

Constructor Detail

Tuple

public Tuple(Object o1,
             Object o2)
Constructs a 2-Tuple using the two given Objects

Parameters:
o1 - The first element (may be null)
o2 - The second element (may be null)
Method Detail

equals

public final boolean equals(Object o)
Determines if the given Tuple equals another Tuple. Returnes true iff both elements are equal (both null or equals() returns true.

Overrides:
equals in class Object
Parameters:
o - the element to compare this tuple with
Returns:
true iff o equals this

hashCode

public final int hashCode()
Generates a hashCode using the two tuple elements.

Overrides:
hashCode in class Object
Returns:
a hashCode built using the hashCodes of the two elements.

toString

public String toString()
Overrides:
toString in class Object

create

public static final Object create(Object o1,
                                  Object o2)
Factory method to create a 2-Tuple


create

public static final Object create(Object o1,
                                  Object o2,
                                  Object o3)
Factory method to create a 3-Tuple


create

public static final Object create(Object o1,
                                  Object o2,
                                  Object o3,
                                  Object o4)
Factory method to create a 4-Tuple


create

public static final Object create(Object o1,
                                  Object o2,
                                  Object o3,
                                  Object o4,
                                  Object o5)
Factory method to create a 5-Tuple


© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003