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 * FieldDefinition 019 * 020 * <hr> 021 * Example to create an instance using the builder pattern 022 * <div class=code-example> 023 * <pre><code class='java'> 024 * FieldDefinition fieldDefinition = FieldDefinition.builder() 025 * .type(typeBuilder -> typeBuilder) 026 * .name("{name}") 027 * .label(labelBuilder -> labelBuilder) 028 * .inputHint(TextInputHint.SINGLE_LINE) 029 * .build() 030 * </code></pre> 031 * </div> 032 */ 033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 034@JsonDeserialize(as = FieldDefinitionImpl.class) 035public interface FieldDefinition { 036 037 /** 038 * 039 * @return type 040 */ 041 @NotNull 042 @Valid 043 @JsonProperty("type") 044 public FieldType getType(); 045 046 /** 047 * <p>The name of the field. The name must be between two and 36 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>). The name must be unique for a given resource type ID. In case there is a field with the same name in another type it has to have the same FieldType also.</p> 048 * @return name 049 */ 050 @NotNull 051 @JsonProperty("name") 052 public String getName(); 053 054 /** 055 * 056 * @return label 057 */ 058 @NotNull 059 @Valid 060 @JsonProperty("label") 061 public LocalizedString getLabel(); 062 063 /** 064 * 065 * @return inputHint 066 */ 067 @NotNull 068 @JsonProperty("inputHint") 069 public TextInputHint getInputHint(); 070 071 /** 072 * set type 073 * @param type value to be set 074 */ 075 076 public void setType(final FieldType type); 077 078 /** 079 * <p>The name of the field. The name must be between two and 36 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>). The name must be unique for a given resource type ID. In case there is a field with the same name in another type it has to have the same FieldType also.</p> 080 * @param name value to be set 081 */ 082 083 public void setName(final String name); 084 085 /** 086 * set label 087 * @param label value to be set 088 */ 089 090 public void setLabel(final LocalizedString label); 091 092 /** 093 * set inputHint 094 * @param inputHint value to be set 095 */ 096 097 public void setInputHint(final TextInputHint inputHint); 098 099 /** 100 * factory method 101 * @return instance of FieldDefinition 102 */ 103 public static FieldDefinition of() { 104 return new FieldDefinitionImpl(); 105 } 106 107 /** 108 * factory method to create a shallow copy FieldDefinition 109 * @param template instance to be copied 110 * @return copy instance 111 */ 112 public static FieldDefinition of(final FieldDefinition template) { 113 FieldDefinitionImpl instance = new FieldDefinitionImpl(); 114 instance.setType(template.getType()); 115 instance.setName(template.getName()); 116 instance.setLabel(template.getLabel()); 117 instance.setInputHint(template.getInputHint()); 118 return instance; 119 } 120 121 /** 122 * factory method to create a deep copy of FieldDefinition 123 * @param template instance to be copied 124 * @return copy instance 125 */ 126 @Nullable 127 public static FieldDefinition deepCopy(@Nullable final FieldDefinition template) { 128 if (template == null) { 129 return null; 130 } 131 FieldDefinitionImpl instance = new FieldDefinitionImpl(); 132 instance.setType(com.commercetools.history.models.common.FieldType.deepCopy(template.getType())); 133 instance.setName(template.getName()); 134 instance.setLabel(com.commercetools.history.models.common.LocalizedString.deepCopy(template.getLabel())); 135 instance.setInputHint(template.getInputHint()); 136 return instance; 137 } 138 139 /** 140 * builder factory method for FieldDefinition 141 * @return builder 142 */ 143 public static FieldDefinitionBuilder builder() { 144 return FieldDefinitionBuilder.of(); 145 } 146 147 /** 148 * create builder for FieldDefinition instance 149 * @param template instance with prefilled values for the builder 150 * @return builder 151 */ 152 public static FieldDefinitionBuilder builder(final FieldDefinition template) { 153 return FieldDefinitionBuilder.of(template); 154 } 155 156 /** 157 * accessor map function 158 * @param <T> mapped type 159 * @param helper function to map the object 160 * @return mapped value 161 */ 162 default <T> T withFieldDefinition(Function<FieldDefinition, T> helper) { 163 return helper.apply(this); 164 } 165 166 /** 167 * gives a TypeReference for usage with Jackson DataBind 168 * @return TypeReference 169 */ 170 public static com.fasterxml.jackson.core.type.TypeReference<FieldDefinition> typeReference() { 171 return new com.fasterxml.jackson.core.type.TypeReference<FieldDefinition>() { 172 @Override 173 public String toString() { 174 return "TypeReference<FieldDefinition>"; 175 } 176 }; 177 } 178}