2010-09-22 23:17:39 +02:00
|
|
|
/**
|
|
|
|
* Very simple wrapper to contain two values in one object.
|
|
|
|
*/
|
2009-06-07 15:40:49 +02:00
|
|
|
public class Pair<T,U> {
|
|
|
|
|
2010-09-22 23:17:39 +02:00
|
|
|
/** The first value */
|
2009-06-07 15:40:49 +02:00
|
|
|
private T first;
|
2010-09-22 23:17:39 +02:00
|
|
|
/** The second value */
|
2009-06-07 15:40:49 +02:00
|
|
|
private U second;
|
|
|
|
|
2010-09-22 23:17:39 +02:00
|
|
|
/**
|
|
|
|
* Creates a new Pair of values.
|
|
|
|
* @param one The first value.
|
|
|
|
* @param two The second value.
|
|
|
|
*/
|
2009-06-07 15:40:49 +02:00
|
|
|
public Pair(T one, U two){
|
|
|
|
this.first = one;
|
|
|
|
this.second = two;
|
|
|
|
}
|
2010-09-22 23:17:39 +02:00
|
|
|
/**
|
|
|
|
* Creates a new Pair of values, both initialized to {@code null}
|
|
|
|
*/
|
|
|
|
public Pair(){ this(null, null); }
|
2009-06-07 15:40:49 +02:00
|
|
|
|
2010-09-22 23:17:39 +02:00
|
|
|
/** Returns the first value of this Pair. */
|
2009-06-07 15:40:49 +02:00
|
|
|
public T getFirst(){ return this.first; }
|
2010-09-22 23:17:39 +02:00
|
|
|
/** Sets the first value of this Pair. */
|
2009-06-07 15:40:49 +02:00
|
|
|
public void setFirst(T value){ this.first = value; }
|
2010-09-22 23:17:39 +02:00
|
|
|
/** Returns the second value of this Pair. */
|
2009-06-07 15:40:49 +02:00
|
|
|
public U getSecond(){ return this.second; }
|
2010-09-22 23:17:39 +02:00
|
|
|
/** Sets the second value of this Pair. */
|
2009-06-07 15:40:49 +02:00
|
|
|
public void setSecond(U value){ this.second = value; }
|
2010-09-22 23:17:39 +02:00
|
|
|
/** Returns true iff both values in this Pair are non-null. */
|
2009-06-07 15:40:49 +02:00
|
|
|
public boolean allSet(){ return this.first != null && this.second != null; }
|
|
|
|
|
|
|
|
}
|