001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.banknew.interfaces;
023:
024: /**
025: * Primary key for bank/Account.
026: */
027: public class AccountPK extends java.lang.Object implements
028: java.io.Serializable {
029: /** The serialVersionUID */
030: private static final long serialVersionUID = -30573929053134518L;
031:
032: private int _hashCode = 0;
033:
034: private StringBuffer _toStringValue = null;
035:
036: public java.lang.String id;
037:
038: public AccountPK() {
039: }
040:
041: public AccountPK(java.lang.String id) {
042: this .id = id;
043: }
044:
045: public java.lang.String getId() {
046: return id;
047: }
048:
049: public void setId(java.lang.String id) {
050: this .id = id;
051: _hashCode = 0;
052: }
053:
054: public int hashCode() {
055: if (_hashCode == 0) {
056: if (this .id != null)
057: _hashCode += this .id.hashCode();
058: }
059:
060: return _hashCode;
061: }
062:
063: public boolean equals(Object obj) {
064: if (!(obj instanceof org.jboss.test.banknew.interfaces.AccountPK))
065: return false;
066:
067: org.jboss.test.banknew.interfaces.AccountPK pk = (org.jboss.test.banknew.interfaces.AccountPK) obj;
068: boolean eq = true;
069:
070: if (obj == null) {
071: eq = false;
072: } else {
073: if (this .id == null
074: && ((org.jboss.test.banknew.interfaces.AccountPK) obj)
075: .getId() == null) {
076: eq = true;
077: } else {
078: if (this .id == null
079: || ((org.jboss.test.banknew.interfaces.AccountPK) obj)
080: .getId() == null) {
081: eq = false;
082: } else {
083: eq = eq && this .id.equals(pk.id);
084: }
085: }
086: }
087:
088: return eq;
089: }
090:
091: /** @return String representation of this pk in the form of [.field1.field2.field3]. */
092: public String toString() {
093: if (_toStringValue == null) {
094: _toStringValue = new StringBuffer("[.");
095: _toStringValue.append(this .id).append('.');
096: _toStringValue.append(']');
097: }
098:
099: return _toStringValue.toString();
100: }
101:
102: }
|