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