001
002package com.commercetools.api.models.common;
003
004import java.util.*;
005import java.util.function.Function;
006
007import javax.annotation.Nullable;
008
009import io.vrap.rmf.base.client.Builder;
010import io.vrap.rmf.base.client.utils.Generated;
011
012/**
013 * AddressBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     Address address = Address.builder()
019 *             .country("{country}")
020 *             .build()
021 * </code></pre>
022 * </div>
023 */
024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
025public class AddressBuilder implements Builder<Address> {
026
027    @Nullable
028    private String id;
029
030    @Nullable
031    private String key;
032
033    private String country;
034
035    @Nullable
036    private String title;
037
038    @Nullable
039    private String salutation;
040
041    @Nullable
042    private String firstName;
043
044    @Nullable
045    private String lastName;
046
047    @Nullable
048    private String streetName;
049
050    @Nullable
051    private String streetNumber;
052
053    @Nullable
054    private String additionalStreetInfo;
055
056    @Nullable
057    private String postalCode;
058
059    @Nullable
060    private String city;
061
062    @Nullable
063    private String region;
064
065    @Nullable
066    private String state;
067
068    @Nullable
069    private String company;
070
071    @Nullable
072    private String department;
073
074    @Nullable
075    private String building;
076
077    @Nullable
078    private String apartment;
079
080    @Nullable
081    private String pOBox;
082
083    @Nullable
084    private String phone;
085
086    @Nullable
087    private String mobile;
088
089    @Nullable
090    private String email;
091
092    @Nullable
093    private String fax;
094
095    @Nullable
096    private String additionalAddressInfo;
097
098    @Nullable
099    private String externalId;
100
101    @Nullable
102    private com.commercetools.api.models.type.CustomFields custom;
103
104    /**
105     * set the value to the id
106     * @param id value to be set
107     * @return Builder
108     */
109
110    public AddressBuilder id(@Nullable final String id) {
111        this.id = id;
112        return this;
113    }
114
115    /**
116     *  <p>User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and <code>itemShippingAddresses</code> (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.</p>
117     * @param key value to be set
118     * @return Builder
119     */
120
121    public AddressBuilder key(@Nullable final String key) {
122        this.key = key;
123        return this;
124    }
125
126    /**
127     *  <p>Name of the country.</p>
128     * @param country value to be set
129     * @return Builder
130     */
131
132    public AddressBuilder country(final String country) {
133        this.country = country;
134        return this;
135    }
136
137    /**
138     *  <p>Title of the contact, for example 'Dr.'</p>
139     * @param title value to be set
140     * @return Builder
141     */
142
143    public AddressBuilder title(@Nullable final String title) {
144        this.title = title;
145        return this;
146    }
147
148    /**
149     *  <p>Salutation of the contact, for example 'Mr.' or 'Ms.'</p>
150     * @param salutation value to be set
151     * @return Builder
152     */
153
154    public AddressBuilder salutation(@Nullable final String salutation) {
155        this.salutation = salutation;
156        return this;
157    }
158
159    /**
160     *  <p>Given name (first name) of the contact.</p>
161     * @param firstName value to be set
162     * @return Builder
163     */
164
165    public AddressBuilder firstName(@Nullable final String firstName) {
166        this.firstName = firstName;
167        return this;
168    }
169
170    /**
171     *  <p>Family name (last name) of the contact.</p>
172     * @param lastName value to be set
173     * @return Builder
174     */
175
176    public AddressBuilder lastName(@Nullable final String lastName) {
177        this.lastName = lastName;
178        return this;
179    }
180
181    /**
182     *  <p>Name of the street.</p>
183     * @param streetName value to be set
184     * @return Builder
185     */
186
187    public AddressBuilder streetName(@Nullable final String streetName) {
188        this.streetName = streetName;
189        return this;
190    }
191
192    /**
193     *  <p>Street number.</p>
194     * @param streetNumber value to be set
195     * @return Builder
196     */
197
198    public AddressBuilder streetNumber(@Nullable final String streetNumber) {
199        this.streetNumber = streetNumber;
200        return this;
201    }
202
203    /**
204     *  <p>Further information on the street address.</p>
205     * @param additionalStreetInfo value to be set
206     * @return Builder
207     */
208
209    public AddressBuilder additionalStreetInfo(@Nullable final String additionalStreetInfo) {
210        this.additionalStreetInfo = additionalStreetInfo;
211        return this;
212    }
213
214    /**
215     *  <p>Postal code.</p>
216     * @param postalCode value to be set
217     * @return Builder
218     */
219
220    public AddressBuilder postalCode(@Nullable final String postalCode) {
221        this.postalCode = postalCode;
222        return this;
223    }
224
225    /**
226     *  <p>Name of the city.</p>
227     * @param city value to be set
228     * @return Builder
229     */
230
231    public AddressBuilder city(@Nullable final String city) {
232        this.city = city;
233        return this;
234    }
235
236    /**
237     *  <p>Name of the region.</p>
238     * @param region value to be set
239     * @return Builder
240     */
241
242    public AddressBuilder region(@Nullable final String region) {
243        this.region = region;
244        return this;
245    }
246
247    /**
248     *  <p>Name of the state, for example, Colorado.</p>
249     * @param state value to be set
250     * @return Builder
251     */
252
253    public AddressBuilder state(@Nullable final String state) {
254        this.state = state;
255        return this;
256    }
257
258    /**
259     *  <p>Name of the company.</p>
260     * @param company value to be set
261     * @return Builder
262     */
263
264    public AddressBuilder company(@Nullable final String company) {
265        this.company = company;
266        return this;
267    }
268
269    /**
270     *  <p>Name of the department.</p>
271     * @param department value to be set
272     * @return Builder
273     */
274
275    public AddressBuilder department(@Nullable final String department) {
276        this.department = department;
277        return this;
278    }
279
280    /**
281     *  <p>Number or name of the building.</p>
282     * @param building value to be set
283     * @return Builder
284     */
285
286    public AddressBuilder building(@Nullable final String building) {
287        this.building = building;
288        return this;
289    }
290
291    /**
292     *  <p>Number or name of the apartment.</p>
293     * @param apartment value to be set
294     * @return Builder
295     */
296
297    public AddressBuilder apartment(@Nullable final String apartment) {
298        this.apartment = apartment;
299        return this;
300    }
301
302    /**
303     *  <p>Post office box number.</p>
304     * @param pOBox value to be set
305     * @return Builder
306     */
307
308    public AddressBuilder pOBox(@Nullable final String pOBox) {
309        this.pOBox = pOBox;
310        return this;
311    }
312
313    /**
314     *  <p>Phone number of the contact.</p>
315     * @param phone value to be set
316     * @return Builder
317     */
318
319    public AddressBuilder phone(@Nullable final String phone) {
320        this.phone = phone;
321        return this;
322    }
323
324    /**
325     *  <p>Mobile phone number of the contact.</p>
326     * @param mobile value to be set
327     * @return Builder
328     */
329
330    public AddressBuilder mobile(@Nullable final String mobile) {
331        this.mobile = mobile;
332        return this;
333    }
334
335    /**
336     *  <p>Email address of the contact.</p>
337     * @param email value to be set
338     * @return Builder
339     */
340
341    public AddressBuilder email(@Nullable final String email) {
342        this.email = email;
343        return this;
344    }
345
346    /**
347     *  <p>Fax number of the contact.</p>
348     * @param fax value to be set
349     * @return Builder
350     */
351
352    public AddressBuilder fax(@Nullable final String fax) {
353        this.fax = fax;
354        return this;
355    }
356
357    /**
358     *  <p>Further information on the Address.</p>
359     * @param additionalAddressInfo value to be set
360     * @return Builder
361     */
362
363    public AddressBuilder additionalAddressInfo(@Nullable final String additionalAddressInfo) {
364        this.additionalAddressInfo = additionalAddressInfo;
365        return this;
366    }
367
368    /**
369     *  <p>ID for the contact used in an external system.</p>
370     * @param externalId value to be set
371     * @return Builder
372     */
373
374    public AddressBuilder externalId(@Nullable final String externalId) {
375        this.externalId = externalId;
376        return this;
377    }
378
379    /**
380     *  <p>Custom Fields defined for the Address.</p>
381     * @param builder function to build the custom value
382     * @return Builder
383     */
384
385    public AddressBuilder custom(
386            Function<com.commercetools.api.models.type.CustomFieldsBuilder, com.commercetools.api.models.type.CustomFieldsBuilder> builder) {
387        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsBuilder.of()).build();
388        return this;
389    }
390
391    /**
392     *  <p>Custom Fields defined for the Address.</p>
393     * @param builder function to build the custom value
394     * @return Builder
395     */
396
397    public AddressBuilder withCustom(
398            Function<com.commercetools.api.models.type.CustomFieldsBuilder, com.commercetools.api.models.type.CustomFields> builder) {
399        this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsBuilder.of());
400        return this;
401    }
402
403    /**
404     *  <p>Custom Fields defined for the Address.</p>
405     * @param custom value to be set
406     * @return Builder
407     */
408
409    public AddressBuilder custom(@Nullable final com.commercetools.api.models.type.CustomFields custom) {
410        this.custom = custom;
411        return this;
412    }
413
414    /**
415     * value of id}
416     * @return id
417     */
418
419    @Nullable
420    public String getId() {
421        return this.id;
422    }
423
424    /**
425     *  <p>User-defined identifier of the Address that must be unique when multiple addresses are referenced in BusinessUnits, Customers, and <code>itemShippingAddresses</code> (LineItem-specific addresses) of a Cart, Order, QuoteRequest, or Quote.</p>
426     * @return key
427     */
428
429    @Nullable
430    public String getKey() {
431        return this.key;
432    }
433
434    /**
435     *  <p>Name of the country.</p>
436     * @return country
437     */
438
439    public String getCountry() {
440        return this.country;
441    }
442
443    /**
444     *  <p>Title of the contact, for example 'Dr.'</p>
445     * @return title
446     */
447
448    @Nullable
449    public String getTitle() {
450        return this.title;
451    }
452
453    /**
454     *  <p>Salutation of the contact, for example 'Mr.' or 'Ms.'</p>
455     * @return salutation
456     */
457
458    @Nullable
459    public String getSalutation() {
460        return this.salutation;
461    }
462
463    /**
464     *  <p>Given name (first name) of the contact.</p>
465     * @return firstName
466     */
467
468    @Nullable
469    public String getFirstName() {
470        return this.firstName;
471    }
472
473    /**
474     *  <p>Family name (last name) of the contact.</p>
475     * @return lastName
476     */
477
478    @Nullable
479    public String getLastName() {
480        return this.lastName;
481    }
482
483    /**
484     *  <p>Name of the street.</p>
485     * @return streetName
486     */
487
488    @Nullable
489    public String getStreetName() {
490        return this.streetName;
491    }
492
493    /**
494     *  <p>Street number.</p>
495     * @return streetNumber
496     */
497
498    @Nullable
499    public String getStreetNumber() {
500        return this.streetNumber;
501    }
502
503    /**
504     *  <p>Further information on the street address.</p>
505     * @return additionalStreetInfo
506     */
507
508    @Nullable
509    public String getAdditionalStreetInfo() {
510        return this.additionalStreetInfo;
511    }
512
513    /**
514     *  <p>Postal code.</p>
515     * @return postalCode
516     */
517
518    @Nullable
519    public String getPostalCode() {
520        return this.postalCode;
521    }
522
523    /**
524     *  <p>Name of the city.</p>
525     * @return city
526     */
527
528    @Nullable
529    public String getCity() {
530        return this.city;
531    }
532
533    /**
534     *  <p>Name of the region.</p>
535     * @return region
536     */
537
538    @Nullable
539    public String getRegion() {
540        return this.region;
541    }
542
543    /**
544     *  <p>Name of the state, for example, Colorado.</p>
545     * @return state
546     */
547
548    @Nullable
549    public String getState() {
550        return this.state;
551    }
552
553    /**
554     *  <p>Name of the company.</p>
555     * @return company
556     */
557
558    @Nullable
559    public String getCompany() {
560        return this.company;
561    }
562
563    /**
564     *  <p>Name of the department.</p>
565     * @return department
566     */
567
568    @Nullable
569    public String getDepartment() {
570        return this.department;
571    }
572
573    /**
574     *  <p>Number or name of the building.</p>
575     * @return building
576     */
577
578    @Nullable
579    public String getBuilding() {
580        return this.building;
581    }
582
583    /**
584     *  <p>Number or name of the apartment.</p>
585     * @return apartment
586     */
587
588    @Nullable
589    public String getApartment() {
590        return this.apartment;
591    }
592
593    /**
594     *  <p>Post office box number.</p>
595     * @return pOBox
596     */
597
598    @Nullable
599    public String getPOBox() {
600        return this.pOBox;
601    }
602
603    /**
604     *  <p>Phone number of the contact.</p>
605     * @return phone
606     */
607
608    @Nullable
609    public String getPhone() {
610        return this.phone;
611    }
612
613    /**
614     *  <p>Mobile phone number of the contact.</p>
615     * @return mobile
616     */
617
618    @Nullable
619    public String getMobile() {
620        return this.mobile;
621    }
622
623    /**
624     *  <p>Email address of the contact.</p>
625     * @return email
626     */
627
628    @Nullable
629    public String getEmail() {
630        return this.email;
631    }
632
633    /**
634     *  <p>Fax number of the contact.</p>
635     * @return fax
636     */
637
638    @Nullable
639    public String getFax() {
640        return this.fax;
641    }
642
643    /**
644     *  <p>Further information on the Address.</p>
645     * @return additionalAddressInfo
646     */
647
648    @Nullable
649    public String getAdditionalAddressInfo() {
650        return this.additionalAddressInfo;
651    }
652
653    /**
654     *  <p>ID for the contact used in an external system.</p>
655     * @return externalId
656     */
657
658    @Nullable
659    public String getExternalId() {
660        return this.externalId;
661    }
662
663    /**
664     *  <p>Custom Fields defined for the Address.</p>
665     * @return custom
666     */
667
668    @Nullable
669    public com.commercetools.api.models.type.CustomFields getCustom() {
670        return this.custom;
671    }
672
673    /**
674     * builds Address with checking for non-null required values
675     * @return Address
676     */
677    public Address build() {
678        Objects.requireNonNull(country, Address.class + ": country is missing");
679        return new AddressImpl(id, key, country, title, salutation, firstName, lastName, streetName, streetNumber,
680            additionalStreetInfo, postalCode, city, region, state, company, department, building, apartment, pOBox,
681            phone, mobile, email, fax, additionalAddressInfo, externalId, custom);
682    }
683
684    /**
685     * builds Address without checking for non-null required values
686     * @return Address
687     */
688    public Address buildUnchecked() {
689        return new AddressImpl(id, key, country, title, salutation, firstName, lastName, streetName, streetNumber,
690            additionalStreetInfo, postalCode, city, region, state, company, department, building, apartment, pOBox,
691            phone, mobile, email, fax, additionalAddressInfo, externalId, custom);
692    }
693
694    /**
695     * factory method for an instance of AddressBuilder
696     * @return builder
697     */
698    public static AddressBuilder of() {
699        return new AddressBuilder();
700    }
701
702    /**
703     * create builder for Address instance
704     * @param template instance with prefilled values for the builder
705     * @return builder
706     */
707    public static AddressBuilder of(final Address template) {
708        AddressBuilder builder = new AddressBuilder();
709        builder.id = template.getId();
710        builder.key = template.getKey();
711        builder.country = template.getCountry();
712        builder.title = template.getTitle();
713        builder.salutation = template.getSalutation();
714        builder.firstName = template.getFirstName();
715        builder.lastName = template.getLastName();
716        builder.streetName = template.getStreetName();
717        builder.streetNumber = template.getStreetNumber();
718        builder.additionalStreetInfo = template.getAdditionalStreetInfo();
719        builder.postalCode = template.getPostalCode();
720        builder.city = template.getCity();
721        builder.region = template.getRegion();
722        builder.state = template.getState();
723        builder.company = template.getCompany();
724        builder.department = template.getDepartment();
725        builder.building = template.getBuilding();
726        builder.apartment = template.getApartment();
727        builder.pOBox = template.getPOBox();
728        builder.phone = template.getPhone();
729        builder.mobile = template.getMobile();
730        builder.email = template.getEmail();
731        builder.fax = template.getFax();
732        builder.additionalAddressInfo = template.getAdditionalAddressInfo();
733        builder.externalId = template.getExternalId();
734        builder.custom = template.getCustom();
735        return builder;
736    }
737
738}