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 * CreatedByBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     CreatedBy createdBy = CreatedBy.builder()
019 *             .build()
020 * </code></pre>
021 * </div>
022 */
023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
024public class CreatedByBuilder implements Builder<CreatedBy> {
025
026    @Nullable
027    private String clientId;
028
029    @Nullable
030    private String externalUserId;
031
032    @Nullable
033    private com.commercetools.api.models.customer.CustomerReference customer;
034
035    @Nullable
036    private String anonymousId;
037
038    /**
039     *  <p><code>id</code> of the APIClient which created the resource.</p>
040     * @param clientId value to be set
041     * @return Builder
042     */
043
044    public CreatedByBuilder clientId(@Nullable final String clientId) {
045        this.clientId = clientId;
046        return this;
047    }
048
049    /**
050     *  <p>External user ID provided by <code>X-External-User-ID</code> HTTP Header.</p>
051     * @param externalUserId value to be set
052     * @return Builder
053     */
054
055    public CreatedByBuilder externalUserId(@Nullable final String externalUserId) {
056        this.externalUserId = externalUserId;
057        return this;
058    }
059
060    /**
061     *  <p>Indicates the Customer who created the resource using a token from the password flow.</p>
062     * @param builder function to build the customer value
063     * @return Builder
064     */
065
066    public CreatedByBuilder customer(
067            Function<com.commercetools.api.models.customer.CustomerReferenceBuilder, com.commercetools.api.models.customer.CustomerReferenceBuilder> builder) {
068        this.customer = builder.apply(com.commercetools.api.models.customer.CustomerReferenceBuilder.of()).build();
069        return this;
070    }
071
072    /**
073     *  <p>Indicates the Customer who created the resource using a token from the password flow.</p>
074     * @param builder function to build the customer value
075     * @return Builder
076     */
077
078    public CreatedByBuilder withCustomer(
079            Function<com.commercetools.api.models.customer.CustomerReferenceBuilder, com.commercetools.api.models.customer.CustomerReference> builder) {
080        this.customer = builder.apply(com.commercetools.api.models.customer.CustomerReferenceBuilder.of());
081        return this;
082    }
083
084    /**
085     *  <p>Indicates the Customer who created the resource using a token from the password flow.</p>
086     * @param customer value to be set
087     * @return Builder
088     */
089
090    public CreatedByBuilder customer(@Nullable final com.commercetools.api.models.customer.CustomerReference customer) {
091        this.customer = customer;
092        return this;
093    }
094
095    /**
096     *  <p>Indicates the anonymous session during which the resource was created.</p>
097     * @param anonymousId value to be set
098     * @return Builder
099     */
100
101    public CreatedByBuilder anonymousId(@Nullable final String anonymousId) {
102        this.anonymousId = anonymousId;
103        return this;
104    }
105
106    /**
107     *  <p><code>id</code> of the APIClient which created the resource.</p>
108     * @return clientId
109     */
110
111    @Nullable
112    public String getClientId() {
113        return this.clientId;
114    }
115
116    /**
117     *  <p>External user ID provided by <code>X-External-User-ID</code> HTTP Header.</p>
118     * @return externalUserId
119     */
120
121    @Nullable
122    public String getExternalUserId() {
123        return this.externalUserId;
124    }
125
126    /**
127     *  <p>Indicates the Customer who created the resource using a token from the password flow.</p>
128     * @return customer
129     */
130
131    @Nullable
132    public com.commercetools.api.models.customer.CustomerReference getCustomer() {
133        return this.customer;
134    }
135
136    /**
137     *  <p>Indicates the anonymous session during which the resource was created.</p>
138     * @return anonymousId
139     */
140
141    @Nullable
142    public String getAnonymousId() {
143        return this.anonymousId;
144    }
145
146    /**
147     * builds CreatedBy with checking for non-null required values
148     * @return CreatedBy
149     */
150    public CreatedBy build() {
151        return new CreatedByImpl(clientId, externalUserId, customer, anonymousId);
152    }
153
154    /**
155     * builds CreatedBy without checking for non-null required values
156     * @return CreatedBy
157     */
158    public CreatedBy buildUnchecked() {
159        return new CreatedByImpl(clientId, externalUserId, customer, anonymousId);
160    }
161
162    /**
163     * factory method for an instance of CreatedByBuilder
164     * @return builder
165     */
166    public static CreatedByBuilder of() {
167        return new CreatedByBuilder();
168    }
169
170    /**
171     * create builder for CreatedBy instance
172     * @param template instance with prefilled values for the builder
173     * @return builder
174     */
175    public static CreatedByBuilder of(final CreatedBy template) {
176        CreatedByBuilder builder = new CreatedByBuilder();
177        builder.clientId = template.getClientId();
178        builder.externalUserId = template.getExternalUserId();
179        builder.customer = template.getCustomer();
180        builder.anonymousId = template.getAnonymousId();
181        return builder;
182    }
183
184}