bf5e589c3d382deb523f0f4f4b583b85efb6be03
[utils] / support / general / src / main / java / org / 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  * @author Erik Brakkee
31  */
32 public class Pair<T, U> {
33
34     private T t;
35
36     private U u;
37
38     /**
39      * Constructs the pair.
40      * 
41      * @param aT
42      *            First object.
43      * @param aU
44      *            Second object.
45      */
46     public Pair(T aT, U aU) {
47         t = aT;
48         u = aU;
49     }
50
51     /**
52      * Copies a pair.
53      * 
54      * @param aPair
55      *            Pair to copy.
56      */
57     public Pair(Pair<T, U> aPair) {
58         t = aPair.t;
59         u = aPair.u;
60     }
61
62     /**
63      * Gets the first object of the pair.
64      * 
65      * @return First object.
66      */
67     public T getFirst() {
68         return t;
69     }
70
71     /**
72      * Gets the second object of the pair.
73      * 
74      * @return Second object.
75      */
76     public U getSecond() {
77         return u;
78     }
79
80 }