001 002package com.commercetools.history.models.common; 003 004import java.util.*; 005import java.util.function.Function; 006 007import io.vrap.rmf.base.client.Builder; 008import io.vrap.rmf.base.client.utils.Generated; 009 010/** 011 * FieldDefinitionBuilder 012 * <hr> 013 * Example to create an instance using the builder pattern 014 * <div class=code-example> 015 * <pre><code class='java'> 016 * FieldDefinition fieldDefinition = FieldDefinition.builder() 017 * .type(typeBuilder -> typeBuilder) 018 * .name("{name}") 019 * .label(labelBuilder -> labelBuilder) 020 * .inputHint(TextInputHint.SINGLE_LINE) 021 * .build() 022 * </code></pre> 023 * </div> 024 */ 025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 026public class FieldDefinitionBuilder implements Builder<FieldDefinition> { 027 028 private com.commercetools.history.models.common.FieldType type; 029 030 private String name; 031 032 private com.commercetools.history.models.common.LocalizedString label; 033 034 private com.commercetools.history.models.common.TextInputHint inputHint; 035 036 /** 037 * set the value to the type using the builder function 038 * @param builder function to build the type value 039 * @return Builder 040 */ 041 042 public FieldDefinitionBuilder type( 043 Function<com.commercetools.history.models.common.FieldTypeBuilder, com.commercetools.history.models.common.FieldTypeBuilder> builder) { 044 this.type = builder.apply(com.commercetools.history.models.common.FieldTypeBuilder.of()).build(); 045 return this; 046 } 047 048 /** 049 * set the value to the type using the builder function 050 * @param builder function to build the type value 051 * @return Builder 052 */ 053 054 public FieldDefinitionBuilder withType( 055 Function<com.commercetools.history.models.common.FieldTypeBuilder, com.commercetools.history.models.common.FieldType> builder) { 056 this.type = builder.apply(com.commercetools.history.models.common.FieldTypeBuilder.of()); 057 return this; 058 } 059 060 /** 061 * set the value to the type 062 * @param type value to be set 063 * @return Builder 064 */ 065 066 public FieldDefinitionBuilder type(final com.commercetools.history.models.common.FieldType type) { 067 this.type = type; 068 return this; 069 } 070 071 /** 072 * <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> 073 * @param name value to be set 074 * @return Builder 075 */ 076 077 public FieldDefinitionBuilder name(final String name) { 078 this.name = name; 079 return this; 080 } 081 082 /** 083 * set the value to the label using the builder function 084 * @param builder function to build the label value 085 * @return Builder 086 */ 087 088 public FieldDefinitionBuilder label( 089 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedStringBuilder> builder) { 090 this.label = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()).build(); 091 return this; 092 } 093 094 /** 095 * set the value to the label using the builder function 096 * @param builder function to build the label value 097 * @return Builder 098 */ 099 100 public FieldDefinitionBuilder withLabel( 101 Function<com.commercetools.history.models.common.LocalizedStringBuilder, com.commercetools.history.models.common.LocalizedString> builder) { 102 this.label = builder.apply(com.commercetools.history.models.common.LocalizedStringBuilder.of()); 103 return this; 104 } 105 106 /** 107 * set the value to the label 108 * @param label value to be set 109 * @return Builder 110 */ 111 112 public FieldDefinitionBuilder label(final com.commercetools.history.models.common.LocalizedString label) { 113 this.label = label; 114 return this; 115 } 116 117 /** 118 * set the value to the inputHint 119 * @param inputHint value to be set 120 * @return Builder 121 */ 122 123 public FieldDefinitionBuilder inputHint(final com.commercetools.history.models.common.TextInputHint inputHint) { 124 this.inputHint = inputHint; 125 return this; 126 } 127 128 /** 129 * value of type} 130 * @return type 131 */ 132 133 public com.commercetools.history.models.common.FieldType getType() { 134 return this.type; 135 } 136 137 /** 138 * <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> 139 * @return name 140 */ 141 142 public String getName() { 143 return this.name; 144 } 145 146 /** 147 * value of label} 148 * @return label 149 */ 150 151 public com.commercetools.history.models.common.LocalizedString getLabel() { 152 return this.label; 153 } 154 155 /** 156 * value of inputHint} 157 * @return inputHint 158 */ 159 160 public com.commercetools.history.models.common.TextInputHint getInputHint() { 161 return this.inputHint; 162 } 163 164 /** 165 * builds FieldDefinition with checking for non-null required values 166 * @return FieldDefinition 167 */ 168 public FieldDefinition build() { 169 Objects.requireNonNull(type, FieldDefinition.class + ": type is missing"); 170 Objects.requireNonNull(name, FieldDefinition.class + ": name is missing"); 171 Objects.requireNonNull(label, FieldDefinition.class + ": label is missing"); 172 Objects.requireNonNull(inputHint, FieldDefinition.class + ": inputHint is missing"); 173 return new FieldDefinitionImpl(type, name, label, inputHint); 174 } 175 176 /** 177 * builds FieldDefinition without checking for non-null required values 178 * @return FieldDefinition 179 */ 180 public FieldDefinition buildUnchecked() { 181 return new FieldDefinitionImpl(type, name, label, inputHint); 182 } 183 184 /** 185 * factory method for an instance of FieldDefinitionBuilder 186 * @return builder 187 */ 188 public static FieldDefinitionBuilder of() { 189 return new FieldDefinitionBuilder(); 190 } 191 192 /** 193 * create builder for FieldDefinition instance 194 * @param template instance with prefilled values for the builder 195 * @return builder 196 */ 197 public static FieldDefinitionBuilder of(final FieldDefinition template) { 198 FieldDefinitionBuilder builder = new FieldDefinitionBuilder(); 199 builder.type = template.getType(); 200 builder.name = template.getName(); 201 builder.label = template.getLabel(); 202 builder.inputHint = template.getInputHint(); 203 return builder; 204 } 205 206}