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 java.util.HashSet;
20  import java.util.Set;
21  
22  import org.apache.commons.lang.builder.CompareToBuilder;
23  import org.apache.commons.lang.builder.EqualsBuilder;
24  import org.apache.commons.lang.builder.HashCodeBuilder;
25  import org.apache.commons.lang.builder.ToStringBuilder;
26  /***
27   *
28   * @author Sven Schauwvliege (Last modified by $Author: shally $)
29   * @version $Revision: 1.4 $ - $Date: 2005/12/20 15:36:45 $
30   */
31  
32  
33  public class Country extends AbstractPersistableObject {
34      
35      /***
36       * constructor
37       * @param country name
38       */
39      public Country(String country) {
40          this.name = country;
41      }
42      /***
43       * constructor
44       */
45      public Country() {  
46      }
47      
48      /***
49       * the name of the country.
50       */
51      private String name;
52      
53      /***
54       * the regions for this country.
55       */
56      private Set region = new HashSet();
57      
58      /***
59       * @return Returns the name.
60       */
61      public String getName() {
62          return name;
63      }
64      
65      /***
66       * @param name The name to set.
67       */
68      public void setName(String name) {
69          this.name = name;
70      }
71      
72      /***
73       * @return Returns the region.
74       */
75      public Set getRegion() {
76          return region;
77      }
78      
79      /***
80       * @param region The region to set.
81       */
82      public void setRegion(Set region) {
83          this.region = region;
84      }
85      
86      /***
87       * adds the region to the country and the country to the region.
88       * @param newregion the region to add.
89       */
90      public void add(Region newregion) {
91          this.region.add(newregion);
92          newregion.setCountry(this);
93      }
94      
95      /***
96       * {@inheritDoc}
97       */
98      public boolean equals(Object o) {
99      	if (!(o instanceof Country)) {
100     	     return false;
101     	   }
102     	   if (this == o) {
103     	     return true;
104     	   }
105     	   Country country = (Country) o;
106     	   return new EqualsBuilder()
107     	   		.appendSuper(super.equals(o))
108     	   		.append(this.name, country.getName())
109     	   		.append(this.region, country.getRegion())
110     	        .isEquals();
111     }
112     
113     
114     /***
115      * {@inheritDoc}
116      */
117     public int hashCode() {
118         return new HashCodeBuilder(89, 113)
119         	.append(this.name)
120             .append(this.region)
121             .toHashCode();
122     }
123     
124     
125     /***
126      * {@inheritDoc}
127      */
128     public int compareTo(Object o) {
129         Country country = (Country) o;
130         return new CompareToBuilder()
131           .appendSuper(super.compareTo(country))
132           .append(this.name, country.getName())
133     	  .append(this.region, country.getRegion())
134           .toComparison();
135     }
136     
137     
138     /***
139      * {@inheritDoc}
140      */
141     public String toString() {
142         return new ToStringBuilder(this)
143         	.appendSuper(super.toString())
144         	.append("name", this.name)    
145         	.append("region", this.region)
146         	.toString();
147     }
148     
149 }
150 /*** 
151  * $Log: Country.java,v $
152  * Revision 1.4  2005/12/20 15:36:45  shally
153  * CheckStyle and PMD changes.
154  *
155  * Revision 1.3  2005/12/09 10:46:55  shally
156  * Opkuis voor checkstyle en PMD
157  *
158  * Revision 1.2  2005/08/31 12:15:09  bme_jcs
159  * refactoring and introduction of apache builders
160  *
161  * Revision 1.1  2005/08/26 07:58:26  ge0ffrey
162  * split up the sources in service, serviceimpl and webclient
163  *
164  * Revision 1.4  2005/08/10 09:04:49  bavo_jcs
165  * Optimized imports according to checkstyle
166  *
167  * Revision 1.3  2005/08/09 12:59:55  bavo_jcs
168  * Optimized imports
169  *
170  * Revision 1.2  2005/08/08 09:38:21  bme_jcs
171  * resolved checkstyle errors
172  *
173  * Revision 1.1  2005/07/05 15:13:11  schauwvliege
174  * added person/contact and location to model
175  * 
176  **/