info.javelot.functionalj.tuple
Class Triple<A,B,C>

java.lang.Object
  extended by info.javelot.functionalj.tuple.Pair<A,B>
      extended by info.javelot.functionalj.tuple.Triple<A,B,C>
All Implemented Interfaces:
Serializable, Comparable<Pair>
Direct Known Subclasses:
Quadruple

public class Triple<A,B,C>
extends Pair<A,B>

Used to create a tuple of three objects. Tuples can be used anywhere there is a need to group objects together, and Triples are used by the Tuples.zip(Collection, Collection, Collection) method.

Author:
Copyright © 2006 Frederic Daoud
See Also:
Serialized Form

Field Summary
 Function1<C,Triple<A,B,C>> third
          Function that returns the third element of the tuple.
 Function3<Triple<A,B,C>,A,B,C> triple
          Function that creates a Triple.
 
Fields inherited from class info.javelot.functionalj.tuple.Pair
first, pair, second
 
Constructor Summary
Triple()
          Default constructor.
Triple(A p_first, B p_second, C p_third)
          Creates a tuple of the three given objects.
 
Method Summary
 int compareTo(Pair p_pair)
          Sort tuples according to the objects that they contain.
 boolean equals(Object p_object)
          Determines if the given object is equal to this object, by comparing the three objects of each triple.
protected  List<String> getStrings()
          Returns a list of the String representations of the objects of the tuple.
 C getThird()
          Returns the third object of the tuple.
 int hashCode()
          Returns the hash code associated with this object.
 void setThird(C p_third)
          Sets the third object of the tuple.
 
Methods inherited from class info.javelot.functionalj.tuple.Pair
getFirst, getSecond, setFirst, setSecond, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

triple

public Function3<Triple<A,B,C>,A,B,C> triple
Function that creates a Triple.


third

public Function1<C,Triple<A,B,C>> third
Function that returns the third element of the tuple.

Constructor Detail

Triple

public Triple()
Default constructor.


Triple

public Triple(A p_first,
              B p_second,
              C p_third)
Creates a tuple of the three given objects.

Parameters:
p_third - the third object of the triple. A null value is accepted. The first two parameters are those accepted by Pair.Pair(Object, Object).
See Also:
Pair.Pair(Object, Object)
Method Detail

getThird

public C getThird()
Returns the third object of the tuple.

Returns:
the third object of the tuple, which may be null.

setThird

public void setThird(C p_third)
Sets the third object of the tuple.

Parameters:
p_third - the third object of the tuple.

hashCode

public int hashCode()
Returns the hash code associated with this object.

Overrides:
hashCode in class Pair<A,B>
Returns:
the hash code associated with this object.
See Also:
Pair.hashCode()

equals

public boolean equals(Object p_object)
Determines if the given object is equal to this object, by comparing the three objects of each triple.

Overrides:
equals in class Pair<A,B>
Parameters:
p_object - the object against which to compare this tuple.
Returns:
true if the pairs contain the same values; false otherwise.
See Also:
Pair.equals(Object)

compareTo

public int compareTo(Pair p_pair)
Description copied from class: Pair
Sort tuples according to the objects that they contain. If the contained in the tuples do not implement the Comparable interface, they are left unsorted.

Specified by:
compareTo in interface Comparable<Pair>
Overrides:
compareTo in class Pair<A,B>

getStrings

protected List<String> getStrings()
Returns a list of the String representations of the objects of the tuple. Here the third object of the tuple is added to the list.

Overrides:
getStrings in class Pair<A,B>
Returns:
a list of the String representations of the objects of the tuple.
See Also:
Pair.toString()