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