001//@formatter:off
002/*
003 * Geo Bad Payer Info Dto - data transfer object to be assembled
004 * Code-Beispiel zum Buch Patterns Kompakt, Verlag Springer Vieweg
005 * Copyright 2014 Karl Eilebrecht
006 * 
007 * Licensed under the Apache License, Version 2.0 (the "License"):
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019//@formatter:on
020package de.calamanari.pk.transferobjectassembler;
021
022import java.io.Serializable;
023
024/**
025 * Geo Bad Payer Info Dto - data transfer object to be assembled, contains information to be collected from different business entities.<br>
026 * In our fictional scenario a list of bad payers related to their location has to be displayed.
027 * 
028 * @author <a href="mailto:Karl.Eilebrecht(a/t)calamanari.de">Karl Eilebrecht</a>
029 */
030public class GeoBadPayerInfoDto implements Serializable {
031
032    /**
033     * for serialization (DTOs are typically serializable)
034     */
035    private static final long serialVersionUID = 2410275631582225430L;
036
037    /**
038     * id of customer
039     */
040    private String customerId = null;
041
042    /**
043     * title field
044     */
045    private String title = null;
046
047    /**
048     * last name
049     */
050    private String lastName = null;
051
052    /**
053     * first name
054     */
055    private String firstName = null;
056
057    /**
058     * Zip code
059     */
060    private String zipCode = null;
061
062    /**
063     * city
064     */
065    private String city = null;
066
067    /**
068     * country
069     */
070    private String country = null;
071
072    /**
073     * some type classification
074     */
075    private String customerType = null;
076
077    /**
078     * there is an invoice not payed yet
079     */
080    private boolean dueInvoice = false;
081
082    /**
083     * Returns a BUILDER to simplify construction
084     * @param customerId mandatory
085     * @return builder instance
086     */
087    public static Builder forCustomer(String customerId) {
088        return new Builder(customerId);
089    }
090
091    /**
092     * Returns the customerId
093     * 
094     * @return customerId
095     */
096    public String getCustomerId() {
097        return customerId;
098    }
099
100    /**
101     * Sets the customerId
102     * 
103     * @param customerId identifier
104     */
105    public void setCustomerId(String customerId) {
106        this.customerId = customerId;
107    }
108
109    /**
110     * Returns customer title
111     * 
112     * @return title of customer
113     */
114    public String getTitle() {
115        return title;
116    }
117
118    /**
119     * Sets the customer's title
120     * 
121     * @param title person's title
122     */
123    public void setTitle(String title) {
124        this.title = title;
125    }
126
127    /**
128     * Returns the last name of customer
129     * 
130     * @return lastName
131     */
132    public String getLastName() {
133        return lastName;
134    }
135
136    /**
137     * Sets the customer's last name
138     * 
139     * @param lastName person's last name
140     */
141    public void setLastName(String lastName) {
142        this.lastName = lastName;
143    }
144
145    /**
146     * Returns the customer's first name
147     * 
148     * @return firstName
149     */
150    public String getFirstName() {
151        return firstName;
152    }
153
154    /**
155     * Sets the customer's first name
156     * 
157     * @param firstName person's first name
158     */
159    public void setFirstName(String firstName) {
160        this.firstName = firstName;
161    }
162
163    /**
164     * Returns the zipcode
165     * 
166     * @return zipCode
167     */
168    public String getZipCode() {
169        return zipCode;
170    }
171
172    /**
173     * Sets the zipCode
174     * 
175     * @param zipCode address field
176     */
177    public void setZipCode(String zipCode) {
178        this.zipCode = zipCode;
179    }
180
181    /**
182     * Returns the city name
183     * 
184     * @return city
185     */
186    public String getCity() {
187        return city;
188    }
189
190    /**
191     * Sets the city name
192     * 
193     * @param city address field
194     */
195    public void setCity(String city) {
196        this.city = city;
197    }
198
199    /**
200     * Returns the country name
201     * 
202     * @return country
203     */
204    public String getCountry() {
205        return country;
206    }
207
208    /**
209     * Sets the country
210     * 
211     * @param country address field
212     */
213    public void setCountry(String country) {
214        this.country = country;
215    }
216
217    /**
218     * Returns the type of customer (classification)
219     * 
220     * @return customerType
221     */
222    public String getCustomerType() {
223        return customerType;
224    }
225
226    /**
227     * Sets the customer type
228     * 
229     * @param customerType type of customer
230     */
231    public void setCustomerType(String customerType) {
232        this.customerType = customerType;
233    }
234
235    /**
236     * Returns whether this customer has an open invoice
237     * 
238     * @return true whether there is an open invoice
239     */
240    public boolean isDueInvoice() {
241        return dueInvoice;
242    }
243
244    /**
245     * Sets the due invoice flag
246     * 
247     * @param dueInvoice true indicates an open invoice not payed yet
248     */
249    public void setDueInvoice(boolean dueInvoice) {
250        this.dueInvoice = dueInvoice;
251    }
252
253    @Override
254    public String toString() {
255        return this.getClass().getSimpleName() + "({customerId=" + customerId + ", title=" + title + ", lastName=" + lastName + ", firstName=" + firstName
256                + ", zipCode=" + zipCode + ", city=" + city + ", country=" + country + ", customerType=" + customerType + ", dueInvoice=" + dueInvoice + "})";
257    }
258
259    /**
260     * Builder to avoid over-parameterized constructor
261     */
262    public static class Builder {
263
264        private final GeoBadPayerInfoDto result;
265
266        /**
267         * Initializes the builder
268         * @param customerId mandatory
269         */
270        Builder(String customerId) {
271            result = new GeoBadPayerInfoDto();
272            result.setCustomerId(customerId);
273        }
274
275        /**
276         * @param title customer property
277         * @return builder
278         */
279        public Builder withTitle(String title) {
280            result.setTitle(title);
281            return this;
282        }
283
284        /**
285         * @param lastName customer property
286         * @return builder
287         */
288        public Builder withLastName(String lastName) {
289            result.setLastName(lastName);
290            return this;
291        }
292
293        /**
294         * @param firstName customer property
295         * @return builder
296         */
297        public Builder withFirstName(String firstName) {
298            result.setFirstName(firstName);
299            return this;
300        }
301
302        /**
303         * @param zipCode address property
304         * @return builder
305         */
306        public Builder withZipCode(String zipCode) {
307            result.setZipCode(zipCode);
308            return this;
309        }
310
311        /**
312         * @param city address property
313         * @return builder
314         */
315        public Builder withCity(String city) {
316            result.setCity(city);
317            return this;
318        }
319
320        /**
321         * @param country address property
322         * @return builder
323         */
324        public Builder withCountry(String country) {
325            result.setCountry(country);
326            return this;
327        }
328
329        /**
330         * @param customerType customer property
331         * @return builder
332         */
333        public Builder withCustomerType(String customerType) {
334            result.setCustomerType(customerType);
335            return this;
336        }
337
338        /**
339         * @param dueInvoice customer property
340         * @return builder
341         */
342        public Builder withDueInvoice(boolean dueInvoice) {
343            result.setDueInvoice(dueInvoice);
344            return this;
345        }
346
347        /**
348         * @return dto with all information
349         */
350        public GeoBadPayerInfoDto build() {
351            return result;
352        }
353    }
354}