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 * ErrorResponseBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     ErrorResponse errorResponse = ErrorResponse.builder()
019 *             .statusCode(1)
020 *             .message("{message}")
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class ErrorResponseBuilder implements Builder<ErrorResponse> {
027
028    private Integer statusCode;
029
030    private String message;
031
032    @Nullable
033    private String error;
034
035    @Nullable
036    private String error_description;
037
038    @Nullable
039    private java.util.List<com.commercetools.history.models.change_history.ErrorObject> errors;
040
041    /**
042     * set the value to the statusCode
043     * @param statusCode value to be set
044     * @return Builder
045     */
046
047    public ErrorResponseBuilder statusCode(final Integer statusCode) {
048        this.statusCode = statusCode;
049        return this;
050    }
051
052    /**
053     * set the value to the message
054     * @param message value to be set
055     * @return Builder
056     */
057
058    public ErrorResponseBuilder message(final String message) {
059        this.message = message;
060        return this;
061    }
062
063    /**
064     * set the value to the error
065     * @param error value to be set
066     * @return Builder
067     */
068
069    public ErrorResponseBuilder error(@Nullable final String error) {
070        this.error = error;
071        return this;
072    }
073
074    /**
075     * set the value to the error_description
076     * @param error_description value to be set
077     * @return Builder
078     */
079
080    public ErrorResponseBuilder error_description(@Nullable final String error_description) {
081        this.error_description = error_description;
082        return this;
083    }
084
085    /**
086     * set values to the errors
087     * @param errors value to be set
088     * @return Builder
089     */
090
091    public ErrorResponseBuilder errors(
092            @Nullable final com.commercetools.history.models.change_history.ErrorObject... errors) {
093        this.errors = new ArrayList<>(Arrays.asList(errors));
094        return this;
095    }
096
097    /**
098     * set value to the errors
099     * @param errors value to be set
100     * @return Builder
101     */
102
103    public ErrorResponseBuilder errors(
104            @Nullable final java.util.List<com.commercetools.history.models.change_history.ErrorObject> errors) {
105        this.errors = errors;
106        return this;
107    }
108
109    /**
110     * add values to the errors
111     * @param errors value to be set
112     * @return Builder
113     */
114
115    public ErrorResponseBuilder plusErrors(
116            @Nullable final com.commercetools.history.models.change_history.ErrorObject... errors) {
117        if (this.errors == null) {
118            this.errors = new ArrayList<>();
119        }
120        this.errors.addAll(Arrays.asList(errors));
121        return this;
122    }
123
124    /**
125     * add the value to the errors using the builder function
126     * @param builder function to build the errors value
127     * @return Builder
128     */
129
130    public ErrorResponseBuilder plusErrors(
131            Function<com.commercetools.history.models.change_history.ErrorObjectBuilder, com.commercetools.history.models.change_history.ErrorObjectBuilder> builder) {
132        if (this.errors == null) {
133            this.errors = new ArrayList<>();
134        }
135        this.errors.add(builder.apply(com.commercetools.history.models.change_history.ErrorObjectBuilder.of()).build());
136        return this;
137    }
138
139    /**
140     * set the value to the errors using the builder function
141     * @param builder function to build the errors value
142     * @return Builder
143     */
144
145    public ErrorResponseBuilder withErrors(
146            Function<com.commercetools.history.models.change_history.ErrorObjectBuilder, com.commercetools.history.models.change_history.ErrorObjectBuilder> builder) {
147        this.errors = new ArrayList<>();
148        this.errors.add(builder.apply(com.commercetools.history.models.change_history.ErrorObjectBuilder.of()).build());
149        return this;
150    }
151
152    /**
153     * add the value to the errors using the builder function
154     * @param builder function to build the errors value
155     * @return Builder
156     */
157
158    public ErrorResponseBuilder addErrors(
159            Function<com.commercetools.history.models.change_history.ErrorObjectBuilder, com.commercetools.history.models.change_history.ErrorObject> builder) {
160        return plusErrors(builder.apply(com.commercetools.history.models.change_history.ErrorObjectBuilder.of()));
161    }
162
163    /**
164     * set the value to the errors using the builder function
165     * @param builder function to build the errors value
166     * @return Builder
167     */
168
169    public ErrorResponseBuilder setErrors(
170            Function<com.commercetools.history.models.change_history.ErrorObjectBuilder, com.commercetools.history.models.change_history.ErrorObject> builder) {
171        return errors(builder.apply(com.commercetools.history.models.change_history.ErrorObjectBuilder.of()));
172    }
173
174    /**
175     * value of statusCode}
176     * @return statusCode
177     */
178
179    public Integer getStatusCode() {
180        return this.statusCode;
181    }
182
183    /**
184     * value of message}
185     * @return message
186     */
187
188    public String getMessage() {
189        return this.message;
190    }
191
192    /**
193     * value of error}
194     * @return error
195     */
196
197    @Nullable
198    public String getError() {
199        return this.error;
200    }
201
202    /**
203     * value of error_description}
204     * @return error_description
205     */
206
207    @Nullable
208    public String getError_description() {
209        return this.error_description;
210    }
211
212    /**
213     * value of errors}
214     * @return errors
215     */
216
217    @Nullable
218    public java.util.List<com.commercetools.history.models.change_history.ErrorObject> getErrors() {
219        return this.errors;
220    }
221
222    /**
223     * builds ErrorResponse with checking for non-null required values
224     * @return ErrorResponse
225     */
226    public ErrorResponse build() {
227        Objects.requireNonNull(statusCode, ErrorResponse.class + ": statusCode is missing");
228        Objects.requireNonNull(message, ErrorResponse.class + ": message is missing");
229        return new ErrorResponseImpl(statusCode, message, error, error_description, errors);
230    }
231
232    /**
233     * builds ErrorResponse without checking for non-null required values
234     * @return ErrorResponse
235     */
236    public ErrorResponse buildUnchecked() {
237        return new ErrorResponseImpl(statusCode, message, error, error_description, errors);
238    }
239
240    /**
241     * factory method for an instance of ErrorResponseBuilder
242     * @return builder
243     */
244    public static ErrorResponseBuilder of() {
245        return new ErrorResponseBuilder();
246    }
247
248    /**
249     * create builder for ErrorResponse instance
250     * @param template instance with prefilled values for the builder
251     * @return builder
252     */
253    public static ErrorResponseBuilder of(final ErrorResponse template) {
254        ErrorResponseBuilder builder = new ErrorResponseBuilder();
255        builder.statusCode = template.getStatusCode();
256        builder.message = template.getMessage();
257        builder.error = template.getError();
258        builder.error_description = template.getErrorDescription();
259        builder.errors = template.getErrors();
260        return builder;
261    }
262
263}