1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package com.rapiddweller.domain.address;
28
29 import com.rapiddweller.common.NullSafeComparator;
30
31
32
33
34
35
36
37
38
39 public class PhoneNumber {
40
41 private String countryCode;
42 private String areaCode;
43 private String localNumber;
44
45 private boolean mobile;
46
47
48
49
50
51
52 public PhoneNumber() {
53 this("", "", "");
54 }
55
56
57
58
59
60
61
62
63 public PhoneNumber(String countryCode, String cityCode,
64 String localNumber) {
65 this(countryCode, cityCode, localNumber, false);
66 }
67
68
69
70
71
72
73
74
75
76 public PhoneNumber(String countryCode, String cityCode, String localNumber,
77 boolean mobile) {
78 this.countryCode = countryCode;
79 this.areaCode = cityCode;
80 this.localNumber = localNumber;
81 this.mobile = mobile;
82 }
83
84
85
86
87
88
89
90
91 public String getCountryCode() {
92 return countryCode;
93 }
94
95
96
97
98
99
100 public void setCountryCode(String countryCode) {
101 this.countryCode = countryCode;
102 }
103
104
105
106
107
108
109 public String getAreaCode() {
110 return areaCode;
111 }
112
113
114
115
116
117
118 public void setAreaCode(String cityCode) {
119 this.areaCode = cityCode;
120 }
121
122
123
124
125
126
127 public String getLocalNumber() {
128 return localNumber;
129 }
130
131
132
133
134
135
136 public void setLocalNumber(String localNumber) {
137 this.localNumber = localNumber;
138 }
139
140
141
142
143
144
145 public boolean isMobile() {
146 return mobile;
147 }
148
149
150
151
152
153
154 public void setMobile(boolean mobile) {
155 this.mobile = mobile;
156 }
157
158
159
160 @Override
161 public String toString() {
162 return "+" + countryCode + '-' + areaCode + '-' + localNumber;
163 }
164
165 @Override
166 public int hashCode() {
167 final int prime = 31;
168 int result = 1;
169 result = prime * result
170 + ((areaCode == null) ? 0 : areaCode.hashCode());
171 result = prime * result
172 + ((countryCode == null) ? 0 : countryCode.hashCode());
173 result = prime * result
174 + ((localNumber == null) ? 0 : localNumber.hashCode());
175 return result;
176 }
177
178 @Override
179 public boolean equals(Object obj) {
180 if (this == obj) {
181 return true;
182 }
183 if (obj == null) {
184 return false;
185 }
186 if (getClass() != obj.getClass()) {
187 return false;
188 }
189 final PhoneNumber../../../com/rapiddweller/domain/address/PhoneNumber.html#PhoneNumber">PhoneNumber that = (PhoneNumber) obj;
190 if (!this.areaCode.equals(that.areaCode)) {
191 return false;
192 }
193 if (!NullSafeComparator.equals(this.countryCode, that.countryCode)) {
194 return false;
195 }
196 return (this.localNumber.equals(that.localNumber));
197 }
198
199 }