001 002package com.commercetools.api.models.error; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.constraints.NotNull; 010 011import com.fasterxml.jackson.annotation.*; 012import com.fasterxml.jackson.databind.annotation.*; 013 014import io.vrap.rmf.base.client.utils.Generated; 015 016/** 017 * <p>Returned when a field has an invalid value.</p> 018 * 019 * <hr> 020 * Example to create an instance using the builder pattern 021 * <div class=code-example> 022 * <pre><code class='java'> 023 * InvalidFieldError invalidFieldError = InvalidFieldError.builder() 024 * .message("{message}") 025 * .field("{field}") 026 * .build() 027 * </code></pre> 028 * </div> 029 */ 030@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 031@JsonDeserialize(as = InvalidFieldErrorImpl.class) 032public interface InvalidFieldError extends ErrorObject { 033 034 /** 035 * discriminator value for InvalidFieldError 036 */ 037 String INVALID_FIELD = "InvalidField"; 038 039 /** 040 * 041 * @return code 042 */ 043 @NotNull 044 @JsonProperty("code") 045 public String getCode(); 046 047 /** 048 * <p><code>"The value $invalidValue is not valid for field $field."</code></p> 049 * @return message 050 */ 051 @NotNull 052 @JsonProperty("message") 053 public String getMessage(); 054 055 /** 056 * <p>Name of the field with the invalid value.</p> 057 * @return field 058 */ 059 @NotNull 060 @JsonProperty("field") 061 public String getField(); 062 063 /** 064 * <p>Value invalid for the field.</p> 065 * @return invalidValue 066 */ 067 @NotNull 068 @JsonProperty("invalidValue") 069 public Object getInvalidValue(); 070 071 /** 072 * <p>Fixed set of allowed values for the field, if any.</p> 073 * @return allowedValues 074 */ 075 076 @JsonProperty("allowedValues") 077 public List<Object> getAllowedValues(); 078 079 /** 080 * <p><code>"The value $invalidValue is not valid for field $field."</code></p> 081 * @param message value to be set 082 */ 083 084 public void setMessage(final String message); 085 086 /** 087 * <p>Name of the field with the invalid value.</p> 088 * @param field value to be set 089 */ 090 091 public void setField(final String field); 092 093 /** 094 * <p>Value invalid for the field.</p> 095 * @param invalidValue value to be set 096 */ 097 098 public void setInvalidValue(final Object invalidValue); 099 100 /** 101 * <p>Fixed set of allowed values for the field, if any.</p> 102 * @param allowedValues values to be set 103 */ 104 105 @JsonIgnore 106 public void setAllowedValues(final Object... allowedValues); 107 108 /** 109 * <p>Fixed set of allowed values for the field, if any.</p> 110 * @param allowedValues values to be set 111 */ 112 113 public void setAllowedValues(final List<Object> allowedValues); 114 115 /** 116 * factory method 117 * @return instance of InvalidFieldError 118 */ 119 public static InvalidFieldError of() { 120 return new InvalidFieldErrorImpl(); 121 } 122 123 /** 124 * factory method to create a shallow copy InvalidFieldError 125 * @param template instance to be copied 126 * @return copy instance 127 */ 128 public static InvalidFieldError of(final InvalidFieldError template) { 129 InvalidFieldErrorImpl instance = new InvalidFieldErrorImpl(); 130 instance.setMessage(template.getMessage()); 131 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 132 instance.setField(template.getField()); 133 instance.setInvalidValue(template.getInvalidValue()); 134 instance.setAllowedValues(template.getAllowedValues()); 135 return instance; 136 } 137 138 /** 139 * factory method to create a deep copy of InvalidFieldError 140 * @param template instance to be copied 141 * @return copy instance 142 */ 143 @Nullable 144 public static InvalidFieldError deepCopy(@Nullable final InvalidFieldError template) { 145 if (template == null) { 146 return null; 147 } 148 InvalidFieldErrorImpl instance = new InvalidFieldErrorImpl(); 149 instance.setMessage(template.getMessage()); 150 Optional.ofNullable(template.values()).ifPresent(t -> t.forEach(instance::setValue)); 151 instance.setField(template.getField()); 152 instance.setInvalidValue(template.getInvalidValue()); 153 instance.setAllowedValues(Optional.ofNullable(template.getAllowedValues()).map(ArrayList::new).orElse(null)); 154 return instance; 155 } 156 157 /** 158 * builder factory method for InvalidFieldError 159 * @return builder 160 */ 161 public static InvalidFieldErrorBuilder builder() { 162 return InvalidFieldErrorBuilder.of(); 163 } 164 165 /** 166 * create builder for InvalidFieldError instance 167 * @param template instance with prefilled values for the builder 168 * @return builder 169 */ 170 public static InvalidFieldErrorBuilder builder(final InvalidFieldError template) { 171 return InvalidFieldErrorBuilder.of(template); 172 } 173 174 /** 175 * accessor map function 176 * @param <T> mapped type 177 * @param helper function to map the object 178 * @return mapped value 179 */ 180 default <T> T withInvalidFieldError(Function<InvalidFieldError, T> helper) { 181 return helper.apply(this); 182 } 183 184 /** 185 * gives a TypeReference for usage with Jackson DataBind 186 * @return TypeReference 187 */ 188 public static com.fasterxml.jackson.core.type.TypeReference<InvalidFieldError> typeReference() { 189 return new com.fasterxml.jackson.core.type.TypeReference<InvalidFieldError>() { 190 @Override 191 public String toString() { 192 return "TypeReference<InvalidFieldError>"; 193 } 194 }; 195 } 196}