001: package org.drools;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.Serializable;
020: import java.math.BigDecimal;
021: import java.math.BigInteger;
022:
023: public class Person implements Serializable, PersonInterface {
024: /**
025: *
026: */
027: private static final long serialVersionUID = 400L;
028: private String name;
029: private String likes;
030: private int age;
031: private BigDecimal bigDecimal;
032: private BigInteger bigInteger;
033: private String hair;
034:
035: private char sex;
036:
037: private boolean alive;
038:
039: private String status;
040:
041: private Cheese cheese;
042:
043: public Person() {
044:
045: }
046:
047: public Person(final String name) {
048: this (name, "", 0);
049: }
050:
051: public Person(final String name, final String likes) {
052: this (name, likes, 0);
053: }
054:
055: public Person(final String name, final String likes, final int age) {
056: this .name = name;
057: this .likes = likes;
058: this .age = age;
059: }
060:
061: /* (non-Javadoc)
062: * @see org.drools.PersonInterface#getStatus()
063: */
064: public String getStatus() {
065: return this .status;
066: }
067:
068: /* (non-Javadoc)
069: * @see org.drools.PersonInterface#setStatus(java.lang.String)
070: */
071: public void setStatus(final String status) {
072: this .status = status;
073: }
074:
075: /* (non-Javadoc)
076: * @see org.drools.PersonInterface#getLikes()
077: */
078: public String getLikes() {
079: return this .likes;
080: }
081:
082: /* (non-Javadoc)
083: * @see org.drools.PersonInterface#getName()
084: */
085: public String getName() {
086: return this .name;
087: }
088:
089: public void setName(final String name) {
090: this .name = name;
091: }
092:
093: /* (non-Javadoc)
094: * @see org.drools.PersonInterface#getAge()
095: */
096: public int getAge() {
097: return this .age;
098: }
099:
100: public void setAge(final int age) {
101: this .age = age;
102: }
103:
104: /* (non-Javadoc)
105: * @see org.drools.PersonInterface#isAlive()
106: */
107: public boolean isAlive() {
108: return this .alive;
109: }
110:
111: /* (non-Javadoc)
112: * @see org.drools.PersonInterface#setAlive(boolean)
113: */
114: public void setAlive(final boolean alive) {
115: this .alive = alive;
116: }
117:
118: /* (non-Javadoc)
119: * @see org.drools.PersonInterface#getSex()
120: */
121: public char getSex() {
122: return this .sex;
123: }
124:
125: /* (non-Javadoc)
126: * @see org.drools.PersonInterface#setSex(char)
127: */
128: public void setSex(final char sex) {
129: this .sex = sex;
130: }
131:
132: public String getHair() {
133: return this .hair;
134: }
135:
136: public void setHair(final String hair) {
137: this .hair = hair;
138: }
139:
140: public String toString() {
141: return "[Person name='" + this .name + "']";
142: }
143:
144: /**
145: * @inheritDoc
146: */
147: public int hashCode() {
148: final int PRIME = 31;
149: int result = 1;
150: result = PRIME * result + this .age;
151: result = PRIME * result + (this .alive ? 1231 : 1237);
152: result = PRIME * result
153: + ((this .name == null) ? 0 : this .name.hashCode());
154: result = PRIME * result + this .sex;
155: return result;
156: }
157:
158: /**
159: * @inheritDoc
160: */
161: public boolean equals(final Object obj) {
162: if (this == obj) {
163: return true;
164: }
165: if (obj == null) {
166: return false;
167: }
168: if (getClass() != obj.getClass()) {
169: return false;
170: }
171: final Person other = (Person) obj;
172: if (this .age != other.age) {
173: return false;
174: }
175: if (this .alive != other.alive) {
176: return false;
177: }
178: if (this .name == null) {
179: if (other.name != null) {
180: return false;
181: }
182: } else if (!this .name.equals(other.name)) {
183: return false;
184: }
185: if (this .sex != other.sex) {
186: return false;
187: }
188: return true;
189: }
190:
191: /* (non-Javadoc)
192: * @see org.drools.PersonInterface#getBigDecimal()
193: */
194: public BigDecimal getBigDecimal() {
195: return this .bigDecimal;
196: }
197:
198: /* (non-Javadoc)
199: * @see org.drools.PersonInterface#setBigDecimal(java.math.BigDecimal)
200: */
201: public void setBigDecimal(final BigDecimal bigDecimal) {
202: this .bigDecimal = bigDecimal;
203: }
204:
205: /* (non-Javadoc)
206: * @see org.drools.PersonInterface#getBigInteger()
207: */
208: public BigInteger getBigInteger() {
209: return this .bigInteger;
210: }
211:
212: /* (non-Javadoc)
213: * @see org.drools.PersonInterface#setBigInteger(java.math.BigInteger)
214: */
215: public void setBigInteger(final BigInteger bigInteger) {
216: this .bigInteger = bigInteger;
217: }
218:
219: public void setLikes(final String likes) {
220: this .likes = likes;
221: }
222:
223: public Cheese getCheese() {
224: return this .cheese;
225: }
226:
227: public void setCheese(final Cheese cheese) {
228: this.cheese = cheese;
229: }
230:
231: }
|