KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > Pair


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.databinding;
12
13 /**
14  * Class Pair. Represents a mathematical pair of objects (a, b).
15  * @since 1.0
16  */

17 public class Pair {
18
19     /**
20      * a in the pair (a, b)
21      */

22     public final Object JavaDoc a;
23
24     /**
25      * b in the pair (a, b)
26      */

27     public final Object JavaDoc b;
28
29     /**
30      * Construct a Pair(a, b)
31      *
32      * @param a a in the pair (a, b)
33      * @param b b in the pair (a, b)
34      */

35     public Pair(Object JavaDoc a, Object JavaDoc b) {
36         this.a = a;
37         this.b = b;
38     }
39
40     /* (non-Javadoc)
41      * @see java.lang.Object#equals(java.lang.Object)
42      */

43     public boolean equals(Object JavaDoc obj) {
44         if (obj.getClass() != Pair.class) {
45             return false;
46         }
47         Pair other = (Pair) obj;
48         return a.equals(other.a) && b.equals(other.b);
49     }
50
51     /* (non-Javadoc)
52      * @see java.lang.Object#hashCode()
53      */

54     public int hashCode() {
55         return a.hashCode() + b.hashCode();
56     }
57 }
58
Popular Tags