com.healthmarketscience.common.util
Class Tuple3<ObjType0,ObjType1,ObjType2>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<Object>
          extended by com.healthmarketscience.common.util.Tuple1<ObjType0>
              extended by com.healthmarketscience.common.util.Tuple2<ObjType0,ObjType1>
                  extended by com.healthmarketscience.common.util.Tuple3<ObjType0,ObjType1,ObjType2>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, Map.Entry<ObjType0,ObjType1>, RandomAccess

public class Tuple3<ObjType0,ObjType1,ObjType2>
extends Tuple2<ObjType0,ObjType1>
implements Cloneable, Serializable

Simple class for holding 3 typed objects.

Author:
James Ahlborn
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.healthmarketscience.common.util.Tuple1
Tuple1.Accessor, Tuple1.IterableIterator<Type>
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Tuple3()
          Initializes a new Tuple3 with null objects.
Tuple3(ObjType0 obj0, ObjType1 obj1, ObjType2 obj2)
          Initializes a new Tuple3 with the given objects.
 
Method Summary
 Tuple3<ObjType0,ObjType1,ObjType2> clone()
          Makes a copy of this Tuple3.
static
<InObjType2>
Collection<InObjType2>
collection2(Collection<? extends Tuple3<?,?,InObjType2>> col)
          Get a Collection adapter for element 2 of the Tuples of the given Collection.
static
<InObjType0,InObjType1,InObjType2>
Tuple3<InObjType0,InObjType1,InObjType2>
create(InObjType0 obj0, InObjType1 obj1, InObjType2 obj2)
          Creates a new Tuple3 object with the provided objects.
 boolean equals(Object o)
          Indicates whether the given Object is equal to this Tuple3.
 Object[] get()
          Get the objects of this tuple as an array.
 Object get(int index)
          Get the value of this tuple identified by index, which must always be 0, 1 or 2, since this tuple class stores exactly three objects.
 ObjType2 get2()
          Returns the third object of this tuple.
 int hashCode()
          Returns a hash code for this Tuple3, based on the objects it contains.
static
<InObjType2>
Iterable<InObjType2>
iterable2(Iterable<? extends Tuple3<?,?,InObjType2>> iable)
          Get an Iterable adapter that returns an Iterator that iterates over element 2 of the Tuples within the given Iterable/Iterator.
 void set(ObjType0 obj0, ObjType1 obj1, ObjType2 obj2)
          Sets the values of this Tuple3.
 void set2(ObjType2 obj)
          Sets the third object of this tuple.
 int size()
          Get the size of this tuple, which is always 3.
 
Methods inherited from class com.healthmarketscience.common.util.Tuple2
collection1, create, create, get1, getKey, getValue, iterable1, set, set1, setValue
 
Methods inherited from class com.healthmarketscience.common.util.Tuple1
collection0, get0, iterable0, set, set0
 
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

Constructor Detail

Tuple3

public Tuple3()
Initializes a new Tuple3 with null objects.


Tuple3

public Tuple3(ObjType0 obj0,
              ObjType1 obj1,
              ObjType2 obj2)
Initializes a new Tuple3 with the given objects. You may want to use create(InObjType0, InObjType1, InObjType2) instead, since it infers the type parameters based on its arguments.

Parameters:
obj0 - the first object to store.
obj1 - the second object to store.
obj2 - the third object to store.
Method Detail

create

public static <InObjType0,InObjType1,InObjType2> Tuple3<InObjType0,InObjType1,InObjType2> create(InObjType0 obj0,
                                                                                                 InObjType1 obj1,
                                                                                                 InObjType2 obj2)
Creates a new Tuple3 object with the provided objects.

Parameters:
obj0 - the first object to store.
obj1 - the second object to store.
obj2 - the third object to store.
Returns:
a new Tuple3 with the given objects.

iterable2

public static <InObjType2> Iterable<InObjType2> iterable2(Iterable<? extends Tuple3<?,?,InObjType2>> iable)
Get an Iterable adapter that returns an Iterator that iterates over element 2 of the Tuples within the given Iterable/Iterator.

Returns:
an Iterable adapter that returns an Iterator that iterates over element 2 of the Tuples within the given Iterable/Iterator.

collection2

public static <InObjType2> Collection<InObjType2> collection2(Collection<? extends Tuple3<?,?,InObjType2>> col)
Get a Collection adapter for element 2 of the Tuples of the given Collection. The returned Collection supports element removal if the given Collection supports element removal, but does not support element addition.

Returns:
a Collection adapter for element 2 of the Tuples of the given Collection.

get2

public final ObjType2 get2()
Returns the third object of this tuple.

Returns:
the third object of this tuple.

set2

public final void set2(ObjType2 obj)
Sets the third object of this tuple.

Parameters:
obj - the object to set as the third object of this tuple.

get

public Object[] get()
Get the objects of this tuple as an array.

Overrides:
get in class Tuple2<ObjType0,ObjType1>
Returns:
the objects of this tuple as an array.

get

public Object get(int index)
Get the value of this tuple identified by index, which must always be 0, 1 or 2, since this tuple class stores exactly three objects.

Specified by:
get in interface List<Object>
Overrides:
get in class Tuple2<ObjType0,ObjType1>
Parameters:
index - the index of the object to retrieve. Must be 0, 1, or 2.
Returns:
the object in this tuple with the given index.

set

public final void set(ObjType0 obj0,
                      ObjType1 obj1,
                      ObjType2 obj2)
Sets the values of this Tuple3.

Parameters:
obj0 - the object to use as the first object of this tuple.
obj1 - the object to use as the second object of this tuple.
obj2 - the object to use as the third object of this tuple.

size

public int size()
Get the size of this tuple, which is always 3.

Specified by:
size in interface Collection<Object>
Specified by:
size in interface List<Object>
Overrides:
size in class Tuple2<ObjType0,ObjType1>
Returns:
the size of this tuple, which is always 3.

clone

public Tuple3<ObjType0,ObjType1,ObjType2> clone()
Makes a copy of this Tuple3.

Overrides:
clone in class Tuple2<ObjType0,ObjType1>
Returns:
a copy of this Tuple3.

equals

public boolean equals(Object o)
Indicates whether the given Object is equal to this Tuple3.

Specified by:
equals in interface Collection<Object>
Specified by:
equals in interface List<Object>
Specified by:
equals in interface Map.Entry<ObjType0,ObjType1>
Overrides:
equals in class Tuple2<ObjType0,ObjType1>
Returns:
  • true if the given Object refers to this Tuple3.
  • true if the given Object is an instance of Tuple3 for which the contained objects are equal to this Tuple3's objects.
  • false otherwise.

  • hashCode

    public int hashCode()
    Returns a hash code for this Tuple3, based on the objects it contains.

    Specified by:
    hashCode in interface Collection<Object>
    Specified by:
    hashCode in interface List<Object>
    Specified by:
    hashCode in interface Map.Entry<ObjType0,ObjType1>
    Overrides:
    hashCode in class Tuple2<ObjType0,ObjType1>
    Returns:
    a hash code for this Tuple3.


    Copyright © 2006-2016 Health Market Science. All Rights Reserved.