net.sf.jpacriteria.tuple
Class Tuple<T>

java.lang.Object
  extended by net.sf.jpacriteria.tuple.Tuple<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Tuple<T>>
Direct Known Subclasses:
Tuple.Pair

public class Tuple<T>
extends java.lang.Object
implements java.lang.Comparable<Tuple<T>>, java.io.Serializable

Tuple implementation useful to keep complex values in collections (both as keys or as values).

Version:
$Id: Tuple.java,v 1.1 2007/04/05 22:08:42 maxim_butov Exp $
Author:
Maxim Butov
See Also:
Serialized Form

Nested Class Summary
static class Tuple.Pair<FIRST,SECOND>
          Two elements tuple.
static class Tuple.Triplet<FIRST,SECOND,THIRD>
          Three elements tuple.
 
Constructor Summary
Tuple(T... objects)
          Creates tuple from objects.
 
Method Summary
 java.util.List<T> asList()
           
 int compareTo(Tuple<T> that)
          Compares tuples
 boolean equals(java.lang.Object obj)
           
 T get(int index)
          Gets index-th element.
static
<A,B> Tuple.Pair<A,B>
getPair(A a, B b)
           
static
<A,B,C> Tuple.Triplet<A,B,C>
getTriplet(A a, B b, C c)
           
static
<X> Tuple<X>
getTuple(X... objects)
           
 int hashCode()
           
 T set(int index, T object)
          Sets index-th element.
 int size()
          Returns elements count.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tuple

public Tuple(T... objects)
Creates tuple from objects.

Parameters:
objects -
Method Detail

getTuple

public static <X> Tuple<X> getTuple(X... objects)

getPair

public static <A,B> Tuple.Pair<A,B> getPair(A a,
                                            B b)

getTriplet

public static <A,B,C> Tuple.Triplet<A,B,C> getTriplet(A a,
                                                      B b,
                                                      C c)

get

public T get(int index)
Gets index-th element.

Parameters:
index -
Returns:
T array

set

public T set(int index,
             T object)
Sets index-th element.

Parameters:
index -
object -
Returns:
T

size

public int size()
Returns elements count.

Returns:
objects length

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

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

compareTo

public int compareTo(Tuple<T> that)
Compares tuples

Specified by:
compareTo in interface java.lang.Comparable<Tuple<T>>
Parameters:
that -
Returns:
result

asList

public java.util.List<T> asList()


Copyright © 2007. All Rights Reserved.