org.entityfs.support.util
Class Pair<T>

java.lang.Object
  extended by org.entityfs.support.util.TwoObjects<T,T>
      extended by org.entityfs.support.util.Pair<T>
All Implemented Interfaces:
Iterable<T>

public class Pair<T>
extends TwoObjects<T,T>
implements Iterable<T>

This is an immutable value object that contains a pair of objects of the same type.

Since:
1.0
Author:
Karl Gustafsson
See Also:
TwoObjects
In_jar:
entityfs-core

Constructor Summary
Pair(T first, T second)
          Create the pair.
 
Method Summary
 List<T> getAsList()
          Get a list with the two objects in a collection.
 Iterator<T> iterator()
          Get an iterator.
 
Methods inherited from class org.entityfs.support.util.TwoObjects
equals, getFirst, getSecond, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair(T first,
            T second)
Create the pair.

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

getAsList

public List<T> getAsList()
Get a list with the two objects in a collection. The first object in the list is the first object in the pair, the second the second.

Returns:
A list with the two objects.

iterator

public Iterator<T> iterator()
Get an iterator. The iterator will first return the first element and then the second element.

Specified by:
iterator in interface Iterable<T>
Returns:
An iterator over the two elements.