View Javadoc

1   /* $Id: Address.java 1102402 2011-05-12 18:03:26Z simonetripodi $
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one or more
4    * contributor license agreements.  See the NOTICE file distributed with
5    * this work for additional information regarding copyright ownership.
6    * The ASF licenses this file to You under the Apache License, Version 2.0
7    * (the "License"); you may not use this file except in compliance with
8    * the License.  You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.digester3.annotations.addressbook;
19  
20  import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
21  import org.apache.commons.digester3.annotations.rules.ObjectCreate;
22  
23  /**
24   * @since 2.1
25   */
26  @ObjectCreate( pattern = "address-book/person/address" )
27  public class Address
28  {
29  
30      @BeanPropertySetter( pattern = "address-book/person/address/type" )
31      private String type;
32  
33      @BeanPropertySetter( pattern = "address-book/person/address/street" )
34      private String street;
35  
36      @BeanPropertySetter( pattern = "address-book/person/address/city" )
37      private String city;
38  
39      @BeanPropertySetter( pattern = "address-book/person/address/state" )
40      private String state;
41  
42      @BeanPropertySetter( pattern = "address-book/person/address/zip" )
43      private String zip;
44  
45      @BeanPropertySetter( pattern = "address-book/person/address/country" )
46      private String country;
47  
48      public String getType()
49      {
50          return type;
51      }
52  
53      public void setType( String type )
54      {
55          this.type = type;
56      }
57  
58      public String getStreet()
59      {
60          return street;
61      }
62  
63      public void setStreet( String street )
64      {
65          this.street = street;
66      }
67  
68      public String getCity()
69      {
70          return city;
71      }
72  
73      public void setCity( String city )
74      {
75          this.city = city;
76      }
77  
78      public String getState()
79      {
80          return state;
81      }
82  
83      public void setState( String state )
84      {
85          this.state = state;
86      }
87  
88      public String getZip()
89      {
90          return zip;
91      }
92  
93      public void setZip( String zip )
94      {
95          this.zip = zip;
96      }
97  
98      public String getCountry()
99      {
100         return country;
101     }
102 
103     public void setCountry( String country )
104     {
105         this.country = country;
106     }
107 
108     @Override
109     public boolean equals( Object obj )
110     {
111         if ( this == obj )
112             return true;
113         if ( obj == null )
114             return false;
115         if ( getClass() != obj.getClass() )
116             return false;
117         Address other = (Address) obj;
118         if ( city == null )
119         {
120             if ( other.city != null )
121                 return false;
122         }
123         else if ( !city.equals( other.city ) )
124             return false;
125         if ( country == null )
126         {
127             if ( other.country != null )
128                 return false;
129         }
130         else if ( !country.equals( other.country ) )
131             return false;
132         if ( state == null )
133         {
134             if ( other.state != null )
135                 return false;
136         }
137         else if ( !state.equals( other.state ) )
138             return false;
139         if ( street == null )
140         {
141             if ( other.street != null )
142                 return false;
143         }
144         else if ( !street.equals( other.street ) )
145             return false;
146         if ( type == null )
147         {
148             if ( other.type != null )
149                 return false;
150         }
151         else if ( !type.equals( other.type ) )
152             return false;
153         if ( zip == null )
154         {
155             if ( other.zip != null )
156                 return false;
157         }
158         else if ( !zip.equals( other.zip ) )
159             return false;
160         return true;
161     }
162 
163     @Override
164     public String toString()
165     {
166         return "Address [city=" + city + ", country=" + country + ", state=" + state + ", street=" + street + ", type="
167             + type + ", zip=" + zip + "]";
168     }
169 
170 }