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