001/* $Id: Address.java 1102402 2011-05-12 18:03:26Z simonetripodi $
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements.  See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License.  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 */
018package org.apache.commons.digester3.annotations.addressbook;
019
020import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
021import org.apache.commons.digester3.annotations.rules.ObjectCreate;
022
023/**
024 * @since 2.1
025 */
026@ObjectCreate( pattern = "address-book/person/address" )
027public class Address
028{
029
030    @BeanPropertySetter( pattern = "address-book/person/address/type" )
031    private String type;
032
033    @BeanPropertySetter( pattern = "address-book/person/address/street" )
034    private String street;
035
036    @BeanPropertySetter( pattern = "address-book/person/address/city" )
037    private String city;
038
039    @BeanPropertySetter( pattern = "address-book/person/address/state" )
040    private String state;
041
042    @BeanPropertySetter( pattern = "address-book/person/address/zip" )
043    private String zip;
044
045    @BeanPropertySetter( pattern = "address-book/person/address/country" )
046    private String country;
047
048    public String getType()
049    {
050        return type;
051    }
052
053    public void setType( String type )
054    {
055        this.type = type;
056    }
057
058    public String getStreet()
059    {
060        return street;
061    }
062
063    public void setStreet( String street )
064    {
065        this.street = street;
066    }
067
068    public String getCity()
069    {
070        return city;
071    }
072
073    public void setCity( String city )
074    {
075        this.city = city;
076    }
077
078    public String getState()
079    {
080        return state;
081    }
082
083    public void setState( String state )
084    {
085        this.state = state;
086    }
087
088    public String getZip()
089    {
090        return zip;
091    }
092
093    public void setZip( String zip )
094    {
095        this.zip = zip;
096    }
097
098    public String getCountry()
099    {
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}