KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > rift > coad > lib > bean > test > TestKey


1 /*
2  * CoadunationLib: The coaduntion implementation library.
3  * Copyright (C) 2006 Rift IT Contracting
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * TestKey.java
20  *
21  * The test key for the proxy test.
22  */

23
24 package com.rift.coad.lib.bean.test;
25
26 /**
27  * The test key for the proxy test.
28  *
29  * @author Brett Chaldecott
30  */

31 public class TestKey implements java.io.Serializable JavaDoc {
32     
33     // private member variables
34
private String JavaDoc key1 = null;
35     private String JavaDoc key2 = null;
36     
37     /** Creates a new instance of TestKey */
38     public TestKey() {
39     }
40     
41     
42     /** Creates a new instance of TestKey */
43     public TestKey(String JavaDoc key1, String JavaDoc key2) {
44         this.key1 = key1;
45         this.key2 = key2;
46     }
47     
48     
49     /**
50      * Retrieve the key 1 value.
51      */

52     public String JavaDoc getKey1() {
53         return key1;
54     }
55     
56     
57     /**
58      * This method sets key 1
59      */

60     public void setKey1(String JavaDoc key1) {
61         this.key1 = key1;
62     }
63     
64     
65     /**
66      * Retrieve the key 2 value.
67      */

68     public String JavaDoc getKey2() {
69         return key1;
70     }
71     
72     
73     /**
74      * This method sets key 2
75      */

76     public void setKey2(String JavaDoc key2) {
77         this.key2 = key2;
78     }
79     
80     
81     /**
82      * This method returns the hash code of the test key.
83      */

84     public int hashCode() {
85         return (key1 + key1).hashCode();
86     }
87     
88     
89     /**
90      * This method returns the hash code of the test key.
91      *
92      * @return TRUE if equals, FALSE if not.
93      * @param value The value to perform the test on.
94      */

95     public boolean equals(Object JavaDoc value) {
96         if (!(value instanceof TestKey)) {
97             return false;
98         }
99         TestKey testKey = (TestKey)value;
100         return (key1.equals(testKey.getKey1()) &&
101                 key2.equals(testKey.getKey2()));
102     }
103 }
104
Popular Tags