001
002package com.commercetools.history.models.change_history;
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 * ModifiedByBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     ModifiedBy modifiedBy = ModifiedBy.builder()
019 *             .id("{id}")
020 *             .type("{type}")
021 *             .isPlatformClient(true)
022 *             .build()
023 * </code></pre>
024 * </div>
025 */
026@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
027public class ModifiedByBuilder implements Builder<ModifiedBy> {
028
029    private String id;
030
031    private String type;
032
033    @Nullable
034    private com.commercetools.history.models.common.Reference customer;
035
036    @Nullable
037    private String anonymousId;
038
039    @Nullable
040    private String clientId;
041
042    private Boolean isPlatformClient;
043
044    /**
045     *  <p>ID of the Merchant Center user who made the change.</p>
046     *  <p>Present only if the change was made in the Merchant Center.</p>
047     * @param id value to be set
048     * @return Builder
049     */
050
051    public ModifiedByBuilder id(final String id) {
052        this.id = id;
053        return this;
054    }
055
056    /**
057     *  <p>Indicates who performed the change.</p>
058     *  <ul>
059     *   <li>If the change was made by a user, the value is <code>"user"</code>.</li>
060     *   <li>If the change was made by an API Client with or without an external user ID, the value is <code>"external-user"</code>.</li>
061     *  </ul>
062     * @param type value to be set
063     * @return Builder
064     */
065
066    public ModifiedByBuilder type(final String type) {
067        this.type = type;
068        return this;
069    }
070
071    /**
072     *  <p>Reference to the Customer who made the change.</p>
073     *  <p>Present only if the change was made using a token from the password flow.</p>
074     * @param builder function to build the customer value
075     * @return Builder
076     */
077
078    public ModifiedByBuilder customer(
079            Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) {
080        this.customer = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build();
081        return this;
082    }
083
084    /**
085     *  <p>Reference to the Customer who made the change.</p>
086     *  <p>Present only if the change was made using a token from the password flow.</p>
087     * @param builder function to build the customer value
088     * @return Builder
089     */
090
091    public ModifiedByBuilder withCustomer(
092            Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) {
093        this.customer = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of());
094        return this;
095    }
096
097    /**
098     *  <p>Reference to the Customer who made the change.</p>
099     *  <p>Present only if the change was made using a token from the password flow.</p>
100     * @param customer value to be set
101     * @return Builder
102     */
103
104    public ModifiedByBuilder customer(@Nullable final com.commercetools.history.models.common.Reference customer) {
105        this.customer = customer;
106        return this;
107    }
108
109    /**
110     *  <p>Present only if the change was made using a token from an anonymous session.</p>
111     * @param anonymousId value to be set
112     * @return Builder
113     */
114
115    public ModifiedByBuilder anonymousId(@Nullable final String anonymousId) {
116        this.anonymousId = anonymousId;
117        return this;
118    }
119
120    /**
121     *  <p>ID of the API Client that made the change.</p>
122     *  <p>Present only if the change was made using an API Client.</p>
123     * @param clientId value to be set
124     * @return Builder
125     */
126
127    public ModifiedByBuilder clientId(@Nullable final String clientId) {
128        this.clientId = clientId;
129        return this;
130    }
131
132    /**
133     *  <p><code>true</code> if the change was made using the Merchant Center or ImpEx.</p>
134     * @param isPlatformClient value to be set
135     * @return Builder
136     */
137
138    public ModifiedByBuilder isPlatformClient(final Boolean isPlatformClient) {
139        this.isPlatformClient = isPlatformClient;
140        return this;
141    }
142
143    /**
144     *  <p>ID of the Merchant Center user who made the change.</p>
145     *  <p>Present only if the change was made in the Merchant Center.</p>
146     * @return id
147     */
148
149    public String getId() {
150        return this.id;
151    }
152
153    /**
154     *  <p>Indicates who performed the change.</p>
155     *  <ul>
156     *   <li>If the change was made by a user, the value is <code>"user"</code>.</li>
157     *   <li>If the change was made by an API Client with or without an external user ID, the value is <code>"external-user"</code>.</li>
158     *  </ul>
159     * @return type
160     */
161
162    public String getType() {
163        return this.type;
164    }
165
166    /**
167     *  <p>Reference to the Customer who made the change.</p>
168     *  <p>Present only if the change was made using a token from the password flow.</p>
169     * @return customer
170     */
171
172    @Nullable
173    public com.commercetools.history.models.common.Reference getCustomer() {
174        return this.customer;
175    }
176
177    /**
178     *  <p>Present only if the change was made using a token from an anonymous session.</p>
179     * @return anonymousId
180     */
181
182    @Nullable
183    public String getAnonymousId() {
184        return this.anonymousId;
185    }
186
187    /**
188     *  <p>ID of the API Client that made the change.</p>
189     *  <p>Present only if the change was made using an API Client.</p>
190     * @return clientId
191     */
192
193    @Nullable
194    public String getClientId() {
195        return this.clientId;
196    }
197
198    /**
199     *  <p><code>true</code> if the change was made using the Merchant Center or ImpEx.</p>
200     * @return isPlatformClient
201     */
202
203    public Boolean getIsPlatformClient() {
204        return this.isPlatformClient;
205    }
206
207    /**
208     * builds ModifiedBy with checking for non-null required values
209     * @return ModifiedBy
210     */
211    public ModifiedBy build() {
212        Objects.requireNonNull(id, ModifiedBy.class + ": id is missing");
213        Objects.requireNonNull(type, ModifiedBy.class + ": type is missing");
214        Objects.requireNonNull(isPlatformClient, ModifiedBy.class + ": isPlatformClient is missing");
215        return new ModifiedByImpl(id, type, customer, anonymousId, clientId, isPlatformClient);
216    }
217
218    /**
219     * builds ModifiedBy without checking for non-null required values
220     * @return ModifiedBy
221     */
222    public ModifiedBy buildUnchecked() {
223        return new ModifiedByImpl(id, type, customer, anonymousId, clientId, isPlatformClient);
224    }
225
226    /**
227     * factory method for an instance of ModifiedByBuilder
228     * @return builder
229     */
230    public static ModifiedByBuilder of() {
231        return new ModifiedByBuilder();
232    }
233
234    /**
235     * create builder for ModifiedBy instance
236     * @param template instance with prefilled values for the builder
237     * @return builder
238     */
239    public static ModifiedByBuilder of(final ModifiedBy template) {
240        ModifiedByBuilder builder = new ModifiedByBuilder();
241        builder.id = template.getId();
242        builder.type = template.getType();
243        builder.customer = template.getCustomer();
244        builder.anonymousId = template.getAnonymousId();
245        builder.clientId = template.getClientId();
246        builder.isPlatformClient = template.getIsPlatformClient();
247        return builder;
248    }
249
250}