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