001: /*
002: * Copyright 2004-2005 OpenSymphony
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy
006: * of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations
014: * under the License.
015: *
016: */
017:
018: /*
019: * Previously Copyright (c) 2001-2004 James House
020: */
021:
022: package org.quartz.utils;
023:
024: /**
025: * <p>
026: * Utility class for storing two pieces of information together.
027: * </p>
028: *
029: * @author <a href="mailto:jeff@binaryfeed.org">Jeffrey Wescott</a>
030: */
031: public class Pair {
032:
033: /*
034: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
035: *
036: * Data members.
037: *
038: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
039: */
040:
041: private Object first;
042:
043: private Object second;
044:
045: /*
046: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
047: *
048: * Interface.
049: *
050: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
051: */
052:
053: /**
054: * <p>
055: * Get the first object in the pair.
056: * </p>
057: *
058: * @return the first object
059: */
060: public final Object getFirst() {
061: return first;
062: }
063:
064: /**
065: * <p>
066: * Set the value of the first object in the pair.
067: * </p>
068: *
069: * @param first
070: * the first object
071: */
072: public final void setFirst(Object first) {
073: this .first = first;
074: }
075:
076: /**
077: * <p>
078: * Get the second object in the pair.
079: * </p>
080: *
081: * @return the second object
082: */
083: public final Object getSecond() {
084: return second;
085: }
086:
087: /**
088: * <p>
089: * Set the second object in the pair.
090: * </p>
091: *
092: * @param second
093: * the second object
094: */
095: public final void setSecond(Object second) {
096: this .second = second;
097: }
098:
099: /**
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 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 e) {
117: return false;
118: }
119: }
120: }
121:
122: public int hashCode() {
123: return (17 * first.hashCode()) + second.hashCode();
124: }
125: }
126:
127: // EOF
|