comparison java/src/uk/ac/qmul/eecs/ccmi/utils/Pair.java @ 0:9418ab7b7f3f

Initial import
author Fiore Martin <fiore@eecs.qmul.ac.uk>
date Fri, 16 Dec 2011 17:35:51 +0000
parents
children d66dd5880081
comparison
equal deleted inserted replaced
-1:000000000000 0:9418ab7b7f3f
1 /*
2 CCmI Editor - A Collaborative Cross-Modal Diagram Editing Tool
3
4 Copyright (C) 2011 Queen Mary University of London (http://ccmi.eecs.qmul.ac.uk/)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package uk.ac.qmul.eecs.ccmi.utils;
21
22 /**
23 *
24 * A Pair of objects.
25 *
26 * @param <T1> The first item type
27 * @param <T2> The second item type
28 */
29 public class Pair<T1,T2> {
30 public Pair(T1 first, T2 second){
31 this.first = first;
32 this.second = second;
33 }
34
35 @Override
36 public int hashCode() {
37 final int prime = 31;
38 int result = 1;
39 result = prime * result + ((first == null) ? 0 : first.hashCode());
40 result = prime * result + ((second == null) ? 0 : second.hashCode());
41 return result;
42 }
43
44 @Override
45 public boolean equals(Object obj) {
46 if (this == obj)
47 return true;
48 if (obj == null)
49 return false;
50 if (getClass() != obj.getClass())
51 return false;
52 @SuppressWarnings("rawtypes")
53 Pair other = (Pair) obj;
54 if (first == null) {
55 if (other.first != null)
56 return false;
57 } else if (!first.equals(other.first))
58 return false;
59 if (second == null) {
60 if (other.second != null)
61 return false;
62 } else if (!second.equals(other.second))
63 return false;
64 return true;
65 }
66
67 public T1 first;
68 public T2 second;
69 }