Search this API

y.util
Class Tuple

java.lang.Object
  extended by y.util.Tuple
All Implemented Interfaces:
java.io.Serializable

public final class Tuple
extends java.lang.Object
implements java.io.Serializable

This class represents an ordered 2-Tuple that is consistent with equals() and hashCode(). Therefore 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
 
Your browser does not support SVG content.

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

Field Detail

o1

public final java.lang.Object o1
The first element of the Tuple


o2

public final java.lang.Object o2
The second element of the Tuple

Constructor Detail

Tuple

public Tuple(java.lang.Object o1,
             java.lang.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(java.lang.Object o)
Determines if the given Tuple equals another Tuple. Returns true iff both elements are equal (both null or equals() returns true.

Overrides:
equals in class java.lang.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 java.lang.Object
Returns:
a hashCode built using the hashCodes of the two elements.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

create

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


create

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


create

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


create

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


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