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 * ExtensionBadResponseErrorBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * ExtensionBadResponseError extensionBadResponseError = ExtensionBadResponseError.builder() 019 * .message("{message}") 020 * .plusExtensionErrors(extensionErrorsBuilder -> extensionErrorsBuilder) 021 * .extensionId("{extensionId}") 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 ExtensionBadResponseErrorBuilder implements Builder<ExtensionBadResponseError> { 028 029 private String message; 030 031 private Map<String, java.lang.Object> values = new HashMap<>(); 032 033 @Nullable 034 private com.commercetools.api.models.common.LocalizedString localizedMessage; 035 036 @Nullable 037 private java.lang.Object extensionExtraInfo; 038 039 private java.util.List<com.commercetools.api.models.error.ExtensionError> extensionErrors; 040 041 @Nullable 042 private String extensionBody; 043 044 @Nullable 045 private Integer extensionStatusCode; 046 047 private String extensionId; 048 049 @Nullable 050 private String extensionKey; 051 052 /** 053 * <p>Description of the invalid Extension response. For example, <code>"The extension did not return the expected JSON."</code>.</p> 054 * @param message value to be set 055 * @return Builder 056 */ 057 058 public ExtensionBadResponseErrorBuilder message(final String message) { 059 this.message = message; 060 return this; 061 } 062 063 /** 064 * <p>Error-specific additional fields.</p> 065 * @param values properties to be set 066 * @return Builder 067 */ 068 069 public ExtensionBadResponseErrorBuilder values(final Map<String, java.lang.Object> values) { 070 this.values = values; 071 return this; 072 } 073 074 /** 075 * <p>Error-specific additional fields.</p> 076 * @param key property name 077 * @param value property value 078 * @return Builder 079 */ 080 081 public ExtensionBadResponseErrorBuilder addValue(final String key, final java.lang.Object value) { 082 if (this.values == null) { 083 values = new HashMap<>(); 084 } 085 values.put(key, value); 086 return this; 087 } 088 089 /** 090 * <p>User-defined localized description of the error.</p> 091 * @param builder function to build the localizedMessage value 092 * @return Builder 093 */ 094 095 public ExtensionBadResponseErrorBuilder localizedMessage( 096 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedStringBuilder> builder) { 097 this.localizedMessage = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()).build(); 098 return this; 099 } 100 101 /** 102 * <p>User-defined localized description of the error.</p> 103 * @param builder function to build the localizedMessage value 104 * @return Builder 105 */ 106 107 public ExtensionBadResponseErrorBuilder withLocalizedMessage( 108 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedString> builder) { 109 this.localizedMessage = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()); 110 return this; 111 } 112 113 /** 114 * <p>User-defined localized description of the error.</p> 115 * @param localizedMessage value to be set 116 * @return Builder 117 */ 118 119 public ExtensionBadResponseErrorBuilder localizedMessage( 120 @Nullable final com.commercetools.api.models.common.LocalizedString localizedMessage) { 121 this.localizedMessage = localizedMessage; 122 return this; 123 } 124 125 /** 126 * <p>Any information that should be returned to the API caller.</p> 127 * @param extensionExtraInfo value to be set 128 * @return Builder 129 */ 130 131 public ExtensionBadResponseErrorBuilder extensionExtraInfo(@Nullable final java.lang.Object extensionExtraInfo) { 132 this.extensionExtraInfo = extensionExtraInfo; 133 return this; 134 } 135 136 /** 137 * <p>Additional errors related to the API Extension.</p> 138 * @param extensionErrors value to be set 139 * @return Builder 140 */ 141 142 public ExtensionBadResponseErrorBuilder extensionErrors( 143 final com.commercetools.api.models.error.ExtensionError... extensionErrors) { 144 this.extensionErrors = new ArrayList<>(Arrays.asList(extensionErrors)); 145 return this; 146 } 147 148 /** 149 * <p>Additional errors related to the API Extension.</p> 150 * @param extensionErrors value to be set 151 * @return Builder 152 */ 153 154 public ExtensionBadResponseErrorBuilder extensionErrors( 155 final java.util.List<com.commercetools.api.models.error.ExtensionError> extensionErrors) { 156 this.extensionErrors = extensionErrors; 157 return this; 158 } 159 160 /** 161 * <p>Additional errors related to the API Extension.</p> 162 * @param extensionErrors value to be set 163 * @return Builder 164 */ 165 166 public ExtensionBadResponseErrorBuilder plusExtensionErrors( 167 final com.commercetools.api.models.error.ExtensionError... extensionErrors) { 168 if (this.extensionErrors == null) { 169 this.extensionErrors = new ArrayList<>(); 170 } 171 this.extensionErrors.addAll(Arrays.asList(extensionErrors)); 172 return this; 173 } 174 175 /** 176 * <p>Additional errors related to the API Extension.</p> 177 * @param builder function to build the extensionErrors value 178 * @return Builder 179 */ 180 181 public ExtensionBadResponseErrorBuilder plusExtensionErrors( 182 Function<com.commercetools.api.models.error.ExtensionErrorBuilder, com.commercetools.api.models.error.ExtensionErrorBuilder> builder) { 183 if (this.extensionErrors == null) { 184 this.extensionErrors = new ArrayList<>(); 185 } 186 this.extensionErrors.add(builder.apply(com.commercetools.api.models.error.ExtensionErrorBuilder.of()).build()); 187 return this; 188 } 189 190 /** 191 * <p>Additional errors related to the API Extension.</p> 192 * @param builder function to build the extensionErrors value 193 * @return Builder 194 */ 195 196 public ExtensionBadResponseErrorBuilder withExtensionErrors( 197 Function<com.commercetools.api.models.error.ExtensionErrorBuilder, com.commercetools.api.models.error.ExtensionErrorBuilder> builder) { 198 this.extensionErrors = new ArrayList<>(); 199 this.extensionErrors.add(builder.apply(com.commercetools.api.models.error.ExtensionErrorBuilder.of()).build()); 200 return this; 201 } 202 203 /** 204 * <p>Additional errors related to the API Extension.</p> 205 * @param builder function to build the extensionErrors value 206 * @return Builder 207 */ 208 209 public ExtensionBadResponseErrorBuilder addExtensionErrors( 210 Function<com.commercetools.api.models.error.ExtensionErrorBuilder, com.commercetools.api.models.error.ExtensionError> builder) { 211 return plusExtensionErrors(builder.apply(com.commercetools.api.models.error.ExtensionErrorBuilder.of())); 212 } 213 214 /** 215 * <p>Additional errors related to the API Extension.</p> 216 * @param builder function to build the extensionErrors value 217 * @return Builder 218 */ 219 220 public ExtensionBadResponseErrorBuilder setExtensionErrors( 221 Function<com.commercetools.api.models.error.ExtensionErrorBuilder, com.commercetools.api.models.error.ExtensionError> builder) { 222 return extensionErrors(builder.apply(com.commercetools.api.models.error.ExtensionErrorBuilder.of())); 223 } 224 225 /** 226 * <p>The response body returned by the Extension.</p> 227 * @param extensionBody value to be set 228 * @return Builder 229 */ 230 231 public ExtensionBadResponseErrorBuilder extensionBody(@Nullable final String extensionBody) { 232 this.extensionBody = extensionBody; 233 return this; 234 } 235 236 /** 237 * <p>Http status code returned by the Extension.</p> 238 * @param extensionStatusCode value to be set 239 * @return Builder 240 */ 241 242 public ExtensionBadResponseErrorBuilder extensionStatusCode(@Nullable final Integer extensionStatusCode) { 243 this.extensionStatusCode = extensionStatusCode; 244 return this; 245 } 246 247 /** 248 * <p>Unique identifier of the Extension.</p> 249 * @param extensionId value to be set 250 * @return Builder 251 */ 252 253 public ExtensionBadResponseErrorBuilder extensionId(final String extensionId) { 254 this.extensionId = extensionId; 255 return this; 256 } 257 258 /** 259 * <p>User-defined unique identifier of the Extension.</p> 260 * @param extensionKey value to be set 261 * @return Builder 262 */ 263 264 public ExtensionBadResponseErrorBuilder extensionKey(@Nullable final String extensionKey) { 265 this.extensionKey = extensionKey; 266 return this; 267 } 268 269 /** 270 * <p>Description of the invalid Extension response. For example, <code>"The extension did not return the expected JSON."</code>.</p> 271 * @return message 272 */ 273 274 public String getMessage() { 275 return this.message; 276 } 277 278 /** 279 * <p>Error-specific additional fields.</p> 280 * @return pattern properties 281 */ 282 283 public Map<String, java.lang.Object> getValues() { 284 return this.values; 285 } 286 287 /** 288 * <p>User-defined localized description of the error.</p> 289 * @return localizedMessage 290 */ 291 292 @Nullable 293 public com.commercetools.api.models.common.LocalizedString getLocalizedMessage() { 294 return this.localizedMessage; 295 } 296 297 /** 298 * <p>Any information that should be returned to the API caller.</p> 299 * @return extensionExtraInfo 300 */ 301 302 @Nullable 303 public java.lang.Object getExtensionExtraInfo() { 304 return this.extensionExtraInfo; 305 } 306 307 /** 308 * <p>Additional errors related to the API Extension.</p> 309 * @return extensionErrors 310 */ 311 312 public java.util.List<com.commercetools.api.models.error.ExtensionError> getExtensionErrors() { 313 return this.extensionErrors; 314 } 315 316 /** 317 * <p>The response body returned by the Extension.</p> 318 * @return extensionBody 319 */ 320 321 @Nullable 322 public String getExtensionBody() { 323 return this.extensionBody; 324 } 325 326 /** 327 * <p>Http status code returned by the Extension.</p> 328 * @return extensionStatusCode 329 */ 330 331 @Nullable 332 public Integer getExtensionStatusCode() { 333 return this.extensionStatusCode; 334 } 335 336 /** 337 * <p>Unique identifier of the Extension.</p> 338 * @return extensionId 339 */ 340 341 public String getExtensionId() { 342 return this.extensionId; 343 } 344 345 /** 346 * <p>User-defined unique identifier of the Extension.</p> 347 * @return extensionKey 348 */ 349 350 @Nullable 351 public String getExtensionKey() { 352 return this.extensionKey; 353 } 354 355 /** 356 * builds ExtensionBadResponseError with checking for non-null required values 357 * @return ExtensionBadResponseError 358 */ 359 public ExtensionBadResponseError build() { 360 Objects.requireNonNull(message, ExtensionBadResponseError.class + ": message is missing"); 361 Objects.requireNonNull(extensionErrors, ExtensionBadResponseError.class + ": extensionErrors is missing"); 362 Objects.requireNonNull(extensionId, ExtensionBadResponseError.class + ": extensionId is missing"); 363 return new ExtensionBadResponseErrorImpl(message, values, localizedMessage, extensionExtraInfo, extensionErrors, 364 extensionBody, extensionStatusCode, extensionId, extensionKey); 365 } 366 367 /** 368 * builds ExtensionBadResponseError without checking for non-null required values 369 * @return ExtensionBadResponseError 370 */ 371 public ExtensionBadResponseError buildUnchecked() { 372 return new ExtensionBadResponseErrorImpl(message, values, localizedMessage, extensionExtraInfo, extensionErrors, 373 extensionBody, extensionStatusCode, extensionId, extensionKey); 374 } 375 376 /** 377 * factory method for an instance of ExtensionBadResponseErrorBuilder 378 * @return builder 379 */ 380 public static ExtensionBadResponseErrorBuilder of() { 381 return new ExtensionBadResponseErrorBuilder(); 382 } 383 384 /** 385 * create builder for ExtensionBadResponseError instance 386 * @param template instance with prefilled values for the builder 387 * @return builder 388 */ 389 public static ExtensionBadResponseErrorBuilder of(final ExtensionBadResponseError template) { 390 ExtensionBadResponseErrorBuilder builder = new ExtensionBadResponseErrorBuilder(); 391 builder.message = template.getMessage(); 392 builder.values = template.values(); 393 builder.localizedMessage = template.getLocalizedMessage(); 394 builder.extensionExtraInfo = template.getExtensionExtraInfo(); 395 builder.extensionErrors = template.getExtensionErrors(); 396 builder.extensionBody = template.getExtensionBody(); 397 builder.extensionStatusCode = template.getExtensionStatusCode(); 398 builder.extensionId = template.getExtensionId(); 399 builder.extensionKey = template.getExtensionKey(); 400 return builder; 401 } 402 403}