View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17  package org.bejug.javacareers.jobs.model;
18  
19  import org.apache.commons.lang.builder.CompareToBuilder;
20  import org.apache.commons.lang.builder.EqualsBuilder;
21  import org.apache.commons.lang.builder.HashCodeBuilder;
22  import org.apache.commons.lang.builder.ToStringBuilder;
23  
24  
25  /***
26   *
27   * @author Sven Schauwvliege (Last modified by $Author: shally $)
28   * @version $Revision: 1.3 $ - $Date: 2005/12/20 15:36:45 $
29   */
30  
31  public class Person extends AbstractPersistableObject{
32  
33      /***
34       * the salutation.
35       */
36      protected String salutation;
37      /***
38       * firstname.
39       */
40      protected String firstName;
41      /***
42       * lastname.
43       */
44      protected String lastName;
45      
46      /***
47       * lastname.
48       */
49      protected String preferredWayOfContact;
50      
51      /***
52       * ways to contact the user.
53       */
54      private Contact contact = new Contact();
55  
56      /***
57       * @return Returns the contact.
58       */
59      public Contact getContact() {
60          return contact;
61      }
62      /***
63       * @param contact The contact to set.
64       */
65      public void setContact(Contact contact) {
66          this.contact = contact;
67      }
68      /***
69       * 
70       * @return firstName String
71       */
72      public String getFirstName() {
73          return firstName;
74      }
75  
76      /***
77       * 
78       * @param firstName String
79       */
80      public void setFirstName(String firstName) {
81          this.firstName = firstName;
82      }
83  
84      /***
85       * 
86       * @return lastName String
87       */
88      public String getLastName() {
89          return lastName;
90      }
91  
92      /***
93       * 
94       * @param lastName String
95       */
96      public void setLastName(String lastName) {
97          this.lastName = lastName;
98      }
99  
100     /***
101      * 
102      * @return salutation String
103      */
104     public String getSalutation() {
105         return salutation;
106     }
107 
108     /***
109      * 
110      * @param salutation String
111      */
112     public void setSalutation(String salutation) {
113         this.salutation = salutation;
114     }
115     /***
116      * @return Returns the preferedWayOfContact.
117      */
118     public String getPreferredWayOfContact() {
119         return preferredWayOfContact;
120     }
121     /***
122      * @param preferredWayOfContact The preferedWayOfContact to set.
123      */
124     public void setPreferredWayOfContact(String preferredWayOfContact) {
125         this.preferredWayOfContact = preferredWayOfContact;
126     }
127     /***
128      * The user address.
129      */
130     private Address address = null;
131 
132     /***
133      * Retrieves the users address.
134      * @return The users address.
135      */
136     public Address getAddress() {
137         return address;
138     }
139     /***
140      * Sets the address of the user.
141      * @param address The users address.
142      */
143     public void setAddress(Address address) {
144         this.address = address;
145     }
146     
147     /***
148 	 * {@inheritDoc}
149 	 */
150 	public int compareTo(Object o) {
151 	     Person person = (Person) o;
152 	     return new CompareToBuilder()
153 	       .appendSuper(super.compareTo(o))
154 	       .append(this.salutation, person.getSalutation())
155 	       .append(this.firstName, person.getFirstName())
156 	       .append(this.lastName, person.getLastName())
157 	       .append(this.preferredWayOfContact, person.getPreferredWayOfContact())
158 	       .append(this.contact, person.getContact())
159 	       .toComparison();
160 	}
161 	
162 	/***
163      * {@inheritDoc}
164      */
165     public boolean equals(Object o) {
166     	if (!(o instanceof Person)) {
167     	     return false;
168     	   }
169     	   if (this == o) {
170     	     return true;
171     	   }
172     	   Person person = (Person) o;
173     	   return new EqualsBuilder()
174     	   		.appendSuper(super.equals(o))
175     	   		.append(this.salutation, person.getSalutation())
176     	   		.append(this.firstName, person.getFirstName())
177     	   		.append(this.lastName, person.getLastName())
178     	   		.append(this.preferredWayOfContact, person.getPreferredWayOfContact())
179     	   		.append(this.contact, person.getContact())
180     	        .isEquals();
181     }
182     
183     
184     /***
185      * {@inheritDoc}
186      */
187     public int hashCode() {
188         return new HashCodeBuilder(259, 983)
189         	.append(this.salutation)
190         	.append(this.firstName)
191         	.append(this.lastName)
192         	.append(this.preferredWayOfContact)
193         	.append(this.contact)
194         	.toHashCode();
195     }
196     
197     
198     /***
199      * {@inheritDoc}
200      */
201     public String toString() {
202     	return new ToStringBuilder(this)
203     		.appendSuper(super.toString())
204     		.append("firstName", this.firstName)
205     		.append("lastName", this.lastName)
206     		.append("salutation", this.salutation)
207     		.append("preferredWay", this.preferredWayOfContact)
208     		.append("contact", this.contact)
209     		.toString();
210     }
211 
212 }
213 /*** 
214  * $Log: Person.java,v $
215  * Revision 1.3  2005/12/20 15:36:45  shally
216  * CheckStyle and PMD changes.
217  *
218  * Revision 1.2  2005/08/31 12:15:09  bme_jcs
219  * refactoring and introduction of apache builders
220  *
221  * Revision 1.1  2005/08/26 07:58:26  ge0ffrey
222  * split up the sources in service, serviceimpl and webclient
223  *
224  * Revision 1.2  2005/07/06 12:10:01  schauwvliege
225  * added person/contact and location to model
226  *
227  * Revision 1.1  2005/07/05 15:13:11  schauwvliege
228  * added person/contact and location to model
229  * 
230  **/