(no commit message)
[utils] / support / general / src / main / java / org / wamblee / general / Pair.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.general;
17
18 /**
19  * Represents a pair of objects. This is inspired on the C++ Standard Template
20  * Library pair template.
21  * 
22  * @param <T>
23  *            Type of the first object.
24  * @param <U>
25  *            Type of the second object.
26  * 
27  * @author Erik Brakkee
28  */
29 public class Pair<T, U> {
30     private T t;
31     private U u;
32
33     /**
34      * Constructs the pair.
35      * 
36      * @param aT
37      *            First object.
38      * @param aU
39      *            Second object.
40      */
41     public Pair(T aT, U aU) {
42         t = aT;
43         u = aU;
44     }
45
46     /**
47      * Copies a pair.
48      * 
49      * @param aPair
50      *            Pair to copy.
51      */
52     public Pair(Pair<T, U> aPair) {
53         t = aPair.t;
54         u = aPair.u;
55     }
56
57     /**
58      * Gets the first object of the pair.
59      * 
60      * @return First object.
61      */
62     public T getFirst() {
63         return t;
64     }
65
66     /**
67      * Gets the second object of the pair.
68      * 
69      * @return Second object.
70      */
71     public U getSecond() {
72         return u;
73     }
74 }