gov.sandia.cognition.util
Class DefaultTriple<FirstType,SecondType,ThirdType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.DefaultTriple<FirstType,SecondType,ThirdType>
Type Parameters:
FirstType - The type of the first object in the triple.
SecondType - The type of second object in the triple.
ThirdType - The type of the third object in the triple.
All Implemented Interfaces:
CloneableSerializable, Triple<FirstType,SecondType,ThirdType>, Serializable, Cloneable
Direct Known Subclasses:
CompositeEvaluatorTriple

public class DefaultTriple<FirstType,SecondType,ThirdType>
extends AbstractCloneableSerializable
implements Triple<FirstType,SecondType,ThirdType>

The DefaultTriple class implements a simple structure for a triple of three objects, potentially of different types.

Since:
2.1
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  FirstType first
          The first object.
protected  SecondType second
          The second object.
protected  ThirdType third
          The third type.
 
Constructor Summary
DefaultTriple()
          Creates a new instance of DefaultTriple with initial null values.
DefaultTriple(FirstType first, SecondType second, ThirdType third)
          Creates a new instance of DefaultTriple.
 
Method Summary
 DefaultTriple<FirstType,SecondType,ThirdType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 FirstType getFirst()
          Gets the first object.
 SecondType getSecond()
          Gets the second object.
 ThirdType getThird()
          Gets the third object.
static
<FirstType,SecondType,ThirdType>
ArrayList<DefaultTriple<FirstType,SecondType,ThirdType>>
mergeCollections(Collection<FirstType> firsts, Collection<SecondType> seconds, Collection<ThirdType> thirds)
          Takes three collections of data of the same size and creates a new single ArrayList<DefaultTriple> out of their elements.
 void setFirst(FirstType first)
          Sets the first object.
 void setSecond(SecondType second)
          Sets the second object.
 void setThird(ThirdType third)
          Sets the third object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

protected FirstType first
The first object.


second

protected SecondType second
The second object.


third

protected ThirdType third
The third type.

Constructor Detail

DefaultTriple

public DefaultTriple()
Creates a new instance of DefaultTriple with initial null values.


DefaultTriple

public DefaultTriple(FirstType first,
                     SecondType second,
                     ThirdType third)
Creates a new instance of DefaultTriple.

Parameters:
first - The first object.
second - The second object.
third - The third object.
Method Detail

clone

public DefaultTriple<FirstType,SecondType,ThirdType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

getFirst

public FirstType getFirst()
Description copied from interface: Triple
Gets the first object.

Specified by:
getFirst in interface Triple<FirstType,SecondType,ThirdType>
Returns:
The first object.

setFirst

public void setFirst(FirstType first)
Sets the first object.

Parameters:
first - The new value for the first object.

getSecond

public SecondType getSecond()
Description copied from interface: Triple
Gets the second object.

Specified by:
getSecond in interface Triple<FirstType,SecondType,ThirdType>
Returns:
The second object.

setSecond

public void setSecond(SecondType second)
Sets the second object.

Parameters:
second - The new value for the second object.

getThird

public ThirdType getThird()
Description copied from interface: Triple
Gets the third object.

Specified by:
getThird in interface Triple<FirstType,SecondType,ThirdType>
Returns:
The third object.

setThird

public void setThird(ThirdType third)
Sets the third object.

Parameters:
third - The new value for the third object.

mergeCollections

public static <FirstType,SecondType,ThirdType> ArrayList<DefaultTriple<FirstType,SecondType,ThirdType>> mergeCollections(Collection<FirstType> firsts,
                                                                                                                         Collection<SecondType> seconds,
                                                                                                                         Collection<ThirdType> thirds)
Takes three collections of data of the same size and creates a new single ArrayList<DefaultTriple> out of their elements.

Type Parameters:
FirstType - The type of the first element.
SecondType - The type of the second element.
ThirdType - The type of the third element.
Parameters:
firsts - A collection of data to transform into the first element of the triple. Must have the same size as seconds and thirds.
seconds - A collection of data to transform into the second element of the triple. Must have the same size as firsts and thirds.
thirds - A collection of data to transform into the third element of the triple. Must have the same size as firsts and seconds.
Returns:
A new array list of triples of the same time as the first, second, and third collections.