01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.test.cmp2.fkmapping.ejb;
23:
24: /**
25: * Primary key for Institute.
26: */
27: public class InstitutePK extends Object implements java.io.Serializable {
28: private int _hashCode = 0;
29: private StringBuffer _toStringValue = null;
30:
31: public String instituteId;
32:
33: public InstitutePK() {
34: }
35:
36: public InstitutePK(String instituteId) {
37: this .instituteId = instituteId;
38: }
39:
40: public String getInstituteId() {
41: return instituteId;
42: }
43:
44: public void setInstituteId(String instituteId) {
45: this .instituteId = instituteId;
46: _hashCode = 0;
47: }
48:
49: public int hashCode() {
50: if (_hashCode == 0) {
51: if (this .instituteId != null)
52: _hashCode += this .instituteId.hashCode();
53: }
54:
55: return _hashCode;
56: }
57:
58: public boolean equals(Object obj) {
59: if (!(obj instanceof InstitutePK))
60: return false;
61:
62: InstitutePK pk = (InstitutePK) obj;
63: boolean eq = true;
64:
65: if (obj == null) {
66: eq = false;
67: } else {
68: if (this .instituteId == null
69: && ((InstitutePK) obj).getInstituteId() == null) {
70: eq = true;
71: } else {
72: if (this .instituteId == null
73: || ((InstitutePK) obj).getInstituteId() == null) {
74: eq = false;
75: } else {
76: eq = eq && this .instituteId.equals(pk.instituteId);
77: }
78: }
79: }
80:
81: return eq;
82: }
83:
84: /** @return String representation of this pk in the form of [.field1.field2.field3]. */
85: public String toString() {
86: if (_toStringValue == null) {
87: _toStringValue = new StringBuffer("[.");
88: _toStringValue.append(this .instituteId).append('.');
89: _toStringValue.append(']');
90: }
91:
92: return _toStringValue.toString();
93: }
94:
95: }
|