01: /**
02: * Copyright (C) 2006 NetMind Consulting Bt.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 3 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package hu.netmind.persistence;
18:
19: /**
20: * This object simply refers to another object, but it overrides the
21: * <code>hashCode()</code> and <code>equals()</code> methods to behave
22: * incorrectly.
23: * @author Brautigam Robert
24: * @version Revision: $Revision$
25: */
26: public class BadHashCode implements Comparable {
27: private int identity;
28: private BadHashCode ref;
29:
30: public BadHashCode() {
31: }
32:
33: public int getIdentity() {
34: return identity;
35: }
36:
37: public void setIdentity(int identity) {
38: this .identity = identity;
39: }
40:
41: public BadHashCode(int identity) {
42: this .identity = identity;
43: }
44:
45: public BadHashCode getRef() {
46: return ref;
47: }
48:
49: public void setRef(BadHashCode ref) {
50: this .ref = ref;
51: }
52:
53: public int compareTo(Object rhs) {
54: return ((BadHashCode) rhs).identity - identity;
55: }
56:
57: public int hashCode(int identity) {
58: return 111111;
59: }
60:
61: public boolean equals(Object obj) {
62: return true;
63: }
64:
65: public String toString() {
66: return "[BadHashCode: " + identity + "]";
67: }
68:
69: }
|