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.cmp2.jbas1361;
023:
024: public class BPK extends Object implements java.io.Serializable {
025: private int _hashCode = 0;
026: private StringBuffer _toStringValue = null;
027:
028: public Integer id;
029: public String name;
030:
031: public BPK() {
032: }
033:
034: public BPK(Integer id, String name) {
035: this .id = id;
036: this .name = name;
037: }
038:
039: public Integer getId() {
040: return id;
041: }
042:
043: public String getName() {
044: return name;
045: }
046:
047: public void setId(Integer id) {
048: this .id = id;
049: _hashCode = 0;
050: }
051:
052: public void setName(String name) {
053: this .name = name;
054: _hashCode = 0;
055: }
056:
057: public int hashCode() {
058: if (_hashCode == 0) {
059: if (this .id != null)
060: _hashCode += this .id.hashCode();
061: if (this .name != null)
062: _hashCode += this .name.hashCode();
063: }
064:
065: return _hashCode;
066: }
067:
068: public boolean equals(Object obj) {
069: if (!(obj instanceof org.jboss.test.cmp2.jbas1361.BPK))
070: return false;
071:
072: org.jboss.test.cmp2.jbas1361.BPK pk = (org.jboss.test.cmp2.jbas1361.BPK) obj;
073: boolean eq = true;
074:
075: if (obj == null) {
076: eq = false;
077: } else {
078: if (this .id == null
079: && ((org.jboss.test.cmp2.jbas1361.BPK) obj).getId() == null) {
080: eq = true;
081: } else {
082: if (this .id == null
083: || ((org.jboss.test.cmp2.jbas1361.BPK) obj)
084: .getId() == null) {
085: eq = false;
086: } else {
087: eq = eq && this .id.equals(pk.id);
088: }
089: }
090: if (this .name == null
091: && ((org.jboss.test.cmp2.jbas1361.BPK) obj)
092: .getName() == null) {
093: eq = true;
094: } else {
095: if (this .name == null
096: || ((org.jboss.test.cmp2.jbas1361.BPK) obj)
097: .getName() == null) {
098: eq = false;
099: } else {
100: eq = eq && this .name.equals(pk.name);
101: }
102: }
103: }
104:
105: return eq;
106: }
107:
108: /** @return String representation of this pk in the form of [.field1.field2.field3]. */
109: public String toString() {
110: if (_toStringValue == null) {
111: _toStringValue = new StringBuffer("[.");
112: _toStringValue.append(this .id).append('.');
113: _toStringValue.append(this .name).append('.');
114: _toStringValue.append(']');
115: }
116:
117: return _toStringValue.toString();
118: }
119: }
|