KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quartz > utils > Pair


1 /*
2  * Copyright 2004-2005 OpenSymphony
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations
14  * under the License.
15  *
16  */

17
18 /*
19  * Previously Copyright (c) 2001-2004 James House
20  */

21
22 package org.quartz.utils;
23
24 /**
25  * <p>
26  * Utility class for storing two pieces of information together.
27  * </p>
28  *
29  * @author <a HREF="mailto:jeff@binaryfeed.org">Jeffrey Wescott</a>
30  */

31 public class Pair {
32
33     /*
34      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35      *
36      * Data members.
37      *
38      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39      */

40
41     private Object JavaDoc first;
42
43     private Object JavaDoc second;
44
45     /*
46      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47      *
48      * Interface.
49      *
50      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51      */

52
53     /**
54      * <p>
55      * Get the first object in the pair.
56      * </p>
57      *
58      * @return the first object
59      */

60     public final Object JavaDoc getFirst() {
61         return first;
62     }
63
64     /**
65      * <p>
66      * Set the value of the first object in the pair.
67      * </p>
68      *
69      * @param first
70      * the first object
71      */

72     public final void setFirst(Object JavaDoc first) {
73         this.first = first;
74     }
75
76     /**
77      * <p>
78      * Get the second object in the pair.
79      * </p>
80      *
81      * @return the second object
82      */

83     public final Object JavaDoc getSecond() {
84         return second;
85     }
86
87     /**
88      * <p>
89      * Set the second object in the pair.
90      * </p>
91      *
92      * @param second
93      * the second object
94      */

95     public final void setSecond(Object JavaDoc second) {
96         this.second = second;
97     }
98
99     /**
100      * <p>
101      * Test equality of this object with that.
102      * </p>
103      *
104      * @param that
105      * object to compare
106      * @return true if objects are equal, false otherwise
107      */

108     public boolean equals(Object JavaDoc that) {
109         if (this == that) {
110             return true;
111         } else {
112             try {
113                 Pair other = (Pair) that;
114                 return (this.first.equals(other.first) && this.second
115                         .equals(other.second));
116             } catch (ClassCastException JavaDoc e) {
117                 return false;
118             }
119         }
120     }
121     
122     public int hashCode() {
123         return (17 * first.hashCode()) + second.hashCode();
124     }
125 }
126
127 // EOF
128
Popular Tags