001 002package com.commercetools.history.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.Valid; 010import javax.validation.constraints.NotNull; 011 012import com.fasterxml.jackson.annotation.*; 013import com.fasterxml.jackson.databind.annotation.*; 014 015import io.vrap.rmf.base.client.utils.Generated; 016 017/** 018 * AttributeDefinition 019 * 020 * <hr> 021 * Example to create an instance using the builder pattern 022 * <div class=code-example> 023 * <pre><code class='java'> 024 * AttributeDefinition attributeDefinition = AttributeDefinition.builder() 025 * .type(typeBuilder -> typeBuilder) 026 * .name("{name}") 027 * .label(labelBuilder -> labelBuilder) 028 * .isRequired(true) 029 * .attributeConstraint(AttributeConstraintEnum.NONE) 030 * .inputTip(inputTipBuilder -> inputTipBuilder) 031 * .inputHint(TextInputHint.SINGLE_LINE) 032 * .isSearchable(true) 033 * .build() 034 * </code></pre> 035 * </div> 036 */ 037@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 038@JsonDeserialize(as = AttributeDefinitionImpl.class) 039public interface AttributeDefinition { 040 041 /** 042 * 043 * @return type 044 */ 045 @NotNull 046 @Valid 047 @JsonProperty("type") 048 public AttributeType getType(); 049 050 /** 051 * <p>The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (<code>_</code>) and the hyphen-minus (<code>-</code>). When using the same <code>name</code> for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an <code>enum</code> or <code>lenum</code> type and sets thereof.</p> 052 * @return name 053 */ 054 @NotNull 055 @JsonProperty("name") 056 public String getName(); 057 058 /** 059 * 060 * @return label 061 */ 062 @NotNull 063 @Valid 064 @JsonProperty("label") 065 public LocalizedString getLabel(); 066 067 /** 068 * <p>Whether the attribute is required to have a value.</p> 069 * @return isRequired 070 */ 071 @NotNull 072 @JsonProperty("isRequired") 073 public Boolean getIsRequired(); 074 075 /** 076 * 077 * @return attributeConstraint 078 */ 079 @NotNull 080 @JsonProperty("attributeConstraint") 081 public AttributeConstraintEnum getAttributeConstraint(); 082 083 /** 084 * 085 * @return inputTip 086 */ 087 @NotNull 088 @Valid 089 @JsonProperty("inputTip") 090 public LocalizedString getInputTip(); 091 092 /** 093 * 094 * @return inputHint 095 */ 096 @NotNull 097 @JsonProperty("inputHint") 098 public TextInputHint getInputHint(); 099 100 /** 101 * <p>Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is <strong>restricted to 10922 characters</strong>. This constraint is enforced at both product creation and product update. If the length of the input exceeds the maximum size an InvalidField error is returned.</p> 102 * @return isSearchable 103 */ 104 @NotNull 105 @JsonProperty("isSearchable") 106 public Boolean getIsSearchable(); 107 108 /** 109 * set type 110 * @param type value to be set 111 */ 112 113 public void setType(final AttributeType type); 114 115 /** 116 * <p>The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (<code>_</code>) and the hyphen-minus (<code>-</code>). When using the same <code>name</code> for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an <code>enum</code> or <code>lenum</code> type and sets thereof.</p> 117 * @param name value to be set 118 */ 119 120 public void setName(final String name); 121 122 /** 123 * set label 124 * @param label value to be set 125 */ 126 127 public void setLabel(final LocalizedString label); 128 129 /** 130 * <p>Whether the attribute is required to have a value.</p> 131 * @param isRequired value to be set 132 */ 133 134 public void setIsRequired(final Boolean isRequired); 135 136 /** 137 * set attributeConstraint 138 * @param attributeConstraint value to be set 139 */ 140 141 public void setAttributeConstraint(final AttributeConstraintEnum attributeConstraint); 142 143 /** 144 * set inputTip 145 * @param inputTip value to be set 146 */ 147 148 public void setInputTip(final LocalizedString inputTip); 149 150 /** 151 * set inputHint 152 * @param inputHint value to be set 153 */ 154 155 public void setInputHint(final TextInputHint inputHint); 156 157 /** 158 * <p>Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is <strong>restricted to 10922 characters</strong>. This constraint is enforced at both product creation and product update. If the length of the input exceeds the maximum size an InvalidField error is returned.</p> 159 * @param isSearchable value to be set 160 */ 161 162 public void setIsSearchable(final Boolean isSearchable); 163 164 /** 165 * factory method 166 * @return instance of AttributeDefinition 167 */ 168 public static AttributeDefinition of() { 169 return new AttributeDefinitionImpl(); 170 } 171 172 /** 173 * factory method to create a shallow copy AttributeDefinition 174 * @param template instance to be copied 175 * @return copy instance 176 */ 177 public static AttributeDefinition of(final AttributeDefinition template) { 178 AttributeDefinitionImpl instance = new AttributeDefinitionImpl(); 179 instance.setType(template.getType()); 180 instance.setName(template.getName()); 181 instance.setLabel(template.getLabel()); 182 instance.setIsRequired(template.getIsRequired()); 183 instance.setAttributeConstraint(template.getAttributeConstraint()); 184 instance.setInputTip(template.getInputTip()); 185 instance.setInputHint(template.getInputHint()); 186 instance.setIsSearchable(template.getIsSearchable()); 187 return instance; 188 } 189 190 /** 191 * factory method to create a deep copy of AttributeDefinition 192 * @param template instance to be copied 193 * @return copy instance 194 */ 195 @Nullable 196 public static AttributeDefinition deepCopy(@Nullable final AttributeDefinition template) { 197 if (template == null) { 198 return null; 199 } 200 AttributeDefinitionImpl instance = new AttributeDefinitionImpl(); 201 instance.setType(com.commercetools.history.models.common.AttributeType.deepCopy(template.getType())); 202 instance.setName(template.getName()); 203 instance.setLabel(com.commercetools.history.models.common.LocalizedString.deepCopy(template.getLabel())); 204 instance.setIsRequired(template.getIsRequired()); 205 instance.setAttributeConstraint(template.getAttributeConstraint()); 206 instance.setInputTip(com.commercetools.history.models.common.LocalizedString.deepCopy(template.getInputTip())); 207 instance.setInputHint(template.getInputHint()); 208 instance.setIsSearchable(template.getIsSearchable()); 209 return instance; 210 } 211 212 /** 213 * builder factory method for AttributeDefinition 214 * @return builder 215 */ 216 public static AttributeDefinitionBuilder builder() { 217 return AttributeDefinitionBuilder.of(); 218 } 219 220 /** 221 * create builder for AttributeDefinition instance 222 * @param template instance with prefilled values for the builder 223 * @return builder 224 */ 225 public static AttributeDefinitionBuilder builder(final AttributeDefinition template) { 226 return AttributeDefinitionBuilder.of(template); 227 } 228 229 /** 230 * accessor map function 231 * @param <T> mapped type 232 * @param helper function to map the object 233 * @return mapped value 234 */ 235 default <T> T withAttributeDefinition(Function<AttributeDefinition, T> helper) { 236 return helper.apply(this); 237 } 238 239 /** 240 * gives a TypeReference for usage with Jackson DataBind 241 * @return TypeReference 242 */ 243 public static com.fasterxml.jackson.core.type.TypeReference<AttributeDefinition> typeReference() { 244 return new com.fasterxml.jackson.core.type.TypeReference<AttributeDefinition>() { 245 @Override 246 public String toString() { 247 return "TypeReference<AttributeDefinition>"; 248 } 249 }; 250 } 251}