1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.digester3.annotations.employee;
19
20 import org.apache.commons.digester3.annotations.rules.BeanPropertySetter;
21 import org.apache.commons.digester3.annotations.rules.ObjectCreate;
22 import org.apache.commons.digester3.annotations.rules.SetProperty;
23 import org.apache.commons.digester3.annotations.rules.SetTop;
24
25
26
27
28 @ObjectCreate( pattern = "employee/address" )
29 public class Address
30 {
31
32 @BeanPropertySetter( pattern = "employee/address/city" )
33 private String city;
34
35 @BeanPropertySetter( pattern = "employee/address/state" )
36 private String state;
37
38 @BeanPropertySetter( pattern = "employee/address/street" )
39 private String street;
40
41 @SetProperty( pattern = "employee/address", attributeName = "place" )
42 private String type;
43
44 @BeanPropertySetter( pattern = "employee/address/zip-code" )
45 private String zipCode;
46
47 @SetTop( pattern = "employee/address" )
48 public void setEmployee( Employee employee )
49 {
50 employee.addAddress( this );
51 }
52
53 public String getCity()
54 {
55 return this.city;
56 }
57
58 public void setCity( String city )
59 {
60 this.city = city;
61 }
62
63 public String getState()
64 {
65 return this.state;
66 }
67
68 public void setState( String state )
69 {
70 this.state = state;
71 }
72
73 public String getStreet()
74 {
75 return this.street;
76 }
77
78 public void setStreet( String street )
79 {
80 this.street = street;
81 }
82
83 public String getType()
84 {
85 return this.type;
86 }
87
88 public void setType( String type )
89 {
90 this.type = type;
91 }
92
93 public String getZipCode()
94 {
95 return this.zipCode;
96 }
97
98 public void setZipCode( String zipCode )
99 {
100 this.zipCode = zipCode;
101 }
102
103 @Override
104 public boolean equals( Object obj )
105 {
106 if ( this == obj )
107 return true;
108 if ( obj == null )
109 return false;
110 if ( getClass() != obj.getClass() )
111 return false;
112 Address other = (Address) obj;
113 if ( this.city == null )
114 {
115 if ( other.getCity() != null )
116 return false;
117 }
118 else if ( !this.city.equals( other.getCity() ) )
119 return false;
120 if ( this.state == null )
121 {
122 if ( other.getState() != null )
123 return false;
124 }
125 else if ( !this.state.equals( other.getState() ) )
126 return false;
127 if ( this.street == null )
128 {
129 if ( other.getStreet() != null )
130 return false;
131 }
132 else if ( !this.street.equals( other.getStreet() ) )
133 return false;
134 if ( this.type == null )
135 {
136 if ( other.getType() != null )
137 return false;
138 }
139 else if ( !this.type.equals( other.getType() ) )
140 return false;
141 if ( this.zipCode == null )
142 {
143 if ( other.getZipCode() != null )
144 return false;
145 }
146 else if ( !this.zipCode.equals( other.getZipCode() ) )
147 return false;
148 return true;
149 }
150
151 @Override
152 public String toString()
153 {
154 return "Address [city=" + city + ", state=" + state + ", street=" + street + ", type=" + type + ", zipCode="
155 + zipCode + "]";
156 }
157
158 }