001
002package com.commercetools.api.models.me;
003
004import java.time.*;
005import java.util.*;
006import java.util.function.Function;
007import java.util.stream.Collectors;
008
009import javax.annotation.Nullable;
010
011import com.fasterxml.jackson.annotation.*;
012import com.fasterxml.jackson.databind.annotation.*;
013
014import io.vrap.rmf.base.client.utils.Generated;
015
016/**
017 *  <p>Draft type to represent the top level of a business. Contains the fields and values of the generic MyBusinessUnitDraft that are used specifically for creating a Company.</p>
018 *
019 * <hr>
020 * Example to create an instance using the builder pattern
021 * <div class=code-example>
022 * <pre><code class='java'>
023 *     MyCompanyDraft myCompanyDraft = MyCompanyDraft.builder()
024 *             .key("{key}")
025 *             .name("{name}")
026 *             .build()
027 * </code></pre>
028 * </div>
029 */
030@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
031@JsonDeserialize(as = MyCompanyDraftImpl.class)
032public interface MyCompanyDraft extends MyBusinessUnitDraft, io.vrap.rmf.base.client.Draft<MyCompanyDraft> {
033
034    /**
035     * discriminator value for MyCompanyDraft
036     */
037    String COMPANY = "Company";
038
039    /**
040     * factory method
041     * @return instance of MyCompanyDraft
042     */
043    public static MyCompanyDraft of() {
044        return new MyCompanyDraftImpl();
045    }
046
047    /**
048     * factory method to create a shallow copy MyCompanyDraft
049     * @param template instance to be copied
050     * @return copy instance
051     */
052    public static MyCompanyDraft of(final MyCompanyDraft template) {
053        MyCompanyDraftImpl instance = new MyCompanyDraftImpl();
054        instance.setKey(template.getKey());
055        instance.setName(template.getName());
056        instance.setContactEmail(template.getContactEmail());
057        instance.setCustom(template.getCustom());
058        instance.setAddresses(template.getAddresses());
059        instance.setShippingAddresses(template.getShippingAddresses());
060        instance.setDefaultShippingAddress(template.getDefaultShippingAddress());
061        instance.setBillingAddresses(template.getBillingAddresses());
062        instance.setDefaultBillingAddress(template.getDefaultBillingAddress());
063        return instance;
064    }
065
066    /**
067     * factory method to create a deep copy of MyCompanyDraft
068     * @param template instance to be copied
069     * @return copy instance
070     */
071    @Nullable
072    public static MyCompanyDraft deepCopy(@Nullable final MyCompanyDraft template) {
073        if (template == null) {
074            return null;
075        }
076        MyCompanyDraftImpl instance = new MyCompanyDraftImpl();
077        instance.setKey(template.getKey());
078        instance.setName(template.getName());
079        instance.setContactEmail(template.getContactEmail());
080        instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom()));
081        instance.setAddresses(Optional.ofNullable(template.getAddresses())
082                .map(t -> t.stream()
083                        .map(com.commercetools.api.models.common.BaseAddress::deepCopy)
084                        .collect(Collectors.toList()))
085                .orElse(null));
086        instance.setShippingAddresses(
087            Optional.ofNullable(template.getShippingAddresses()).map(ArrayList::new).orElse(null));
088        instance.setDefaultShippingAddress(template.getDefaultShippingAddress());
089        instance.setBillingAddresses(
090            Optional.ofNullable(template.getBillingAddresses()).map(ArrayList::new).orElse(null));
091        instance.setDefaultBillingAddress(template.getDefaultBillingAddress());
092        return instance;
093    }
094
095    /**
096     * builder factory method for MyCompanyDraft
097     * @return builder
098     */
099    public static MyCompanyDraftBuilder builder() {
100        return MyCompanyDraftBuilder.of();
101    }
102
103    /**
104     * create builder for MyCompanyDraft instance
105     * @param template instance with prefilled values for the builder
106     * @return builder
107     */
108    public static MyCompanyDraftBuilder builder(final MyCompanyDraft template) {
109        return MyCompanyDraftBuilder.of(template);
110    }
111
112    /**
113     * accessor map function
114     * @param <T> mapped type
115     * @param helper function to map the object
116     * @return mapped value
117     */
118    default <T> T withMyCompanyDraft(Function<MyCompanyDraft, T> helper) {
119        return helper.apply(this);
120    }
121
122    /**
123     * gives a TypeReference for usage with Jackson DataBind
124     * @return TypeReference
125     */
126    public static com.fasterxml.jackson.core.type.TypeReference<MyCompanyDraft> typeReference() {
127        return new com.fasterxml.jackson.core.type.TypeReference<MyCompanyDraft>() {
128            @Override
129            public String toString() {
130                return "TypeReference<MyCompanyDraft>";
131            }
132        };
133    }
134}