Java: Added some simple JavaDoc to the Pair class.

This commit is contained in:
barubary 2010-09-22 21:17:39 +00:00
parent 2bd45587cf
commit 1ab4aa0c69
1 changed files with 19 additions and 1 deletions

View File

@ -1,18 +1,36 @@
/**
* Very simple wrapper to contain two values in one object.
*/
public class Pair<T,U> {
/** The first value */
private T first;
/** The second value */
private U second;
/**
* Creates a new Pair of values.
* @param one The first value.
* @param two The second value.
*/
public Pair(T one, U two){
this.first = one;
this.second = two;
}
public Pair(){}
/**
* Creates a new Pair of values, both initialized to {@code null}
*/
public Pair(){ this(null, null); }
/** Returns the first value of this Pair. */
public T getFirst(){ return this.first; }
/** Sets the first value of this Pair. */
public void setFirst(T value){ this.first = value; }
/** Returns the second value of this Pair. */
public U getSecond(){ return this.second; }
/** Sets the second value of this Pair. */
public void setSecond(U value){ this.second = value; }
/** Returns true iff both values in this Pair are non-null. */
public boolean allSet(){ return this.first != null && this.second != null; }
}