001 002package com.commercetools.api.models.channel; 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 * ChannelDraftBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * ChannelDraft channelDraft = ChannelDraft.builder() 019 * .key("{key}") 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class ChannelDraftBuilder implements Builder<ChannelDraft> { 026 027 private String key; 028 029 @Nullable 030 private java.util.List<com.commercetools.api.models.channel.ChannelRoleEnum> roles; 031 032 @Nullable 033 private com.commercetools.api.models.common.LocalizedString name; 034 035 @Nullable 036 private com.commercetools.api.models.common.LocalizedString description; 037 038 @Nullable 039 private com.commercetools.api.models.common.BaseAddress address; 040 041 @Nullable 042 private com.commercetools.api.models.type.CustomFieldsDraft custom; 043 044 @Nullable 045 private com.commercetools.api.models.common.GeoJson geoLocation; 046 047 /** 048 * <p>User-defined unique identifier for the Channel.</p> 049 * @param key value to be set 050 * @return Builder 051 */ 052 053 public ChannelDraftBuilder key(final String key) { 054 this.key = key; 055 return this; 056 } 057 058 /** 059 * <p>Roles of the Channel. Each channel must have at least one role. If not specified, then <code>InventorySupply</code> is assigned by default.</p> 060 * @param roles value to be set 061 * @return Builder 062 */ 063 064 public ChannelDraftBuilder roles(@Nullable final com.commercetools.api.models.channel.ChannelRoleEnum... roles) { 065 this.roles = new ArrayList<>(Arrays.asList(roles)); 066 return this; 067 } 068 069 /** 070 * <p>Roles of the Channel. Each channel must have at least one role. If not specified, then <code>InventorySupply</code> is assigned by default.</p> 071 * @param roles value to be set 072 * @return Builder 073 */ 074 075 public ChannelDraftBuilder roles( 076 @Nullable final java.util.List<com.commercetools.api.models.channel.ChannelRoleEnum> roles) { 077 this.roles = roles; 078 return this; 079 } 080 081 /** 082 * <p>Roles of the Channel. Each channel must have at least one role. If not specified, then <code>InventorySupply</code> is assigned by default.</p> 083 * @param roles value to be set 084 * @return Builder 085 */ 086 087 public ChannelDraftBuilder plusRoles( 088 @Nullable final com.commercetools.api.models.channel.ChannelRoleEnum... roles) { 089 if (this.roles == null) { 090 this.roles = new ArrayList<>(); 091 } 092 this.roles.addAll(Arrays.asList(roles)); 093 return this; 094 } 095 096 /** 097 * <p>Name of the Channel.</p> 098 * @param builder function to build the name value 099 * @return Builder 100 */ 101 102 public ChannelDraftBuilder name( 103 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedStringBuilder> builder) { 104 this.name = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()).build(); 105 return this; 106 } 107 108 /** 109 * <p>Name of the Channel.</p> 110 * @param builder function to build the name value 111 * @return Builder 112 */ 113 114 public ChannelDraftBuilder withName( 115 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedString> builder) { 116 this.name = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()); 117 return this; 118 } 119 120 /** 121 * <p>Name of the Channel.</p> 122 * @param name value to be set 123 * @return Builder 124 */ 125 126 public ChannelDraftBuilder name(@Nullable final com.commercetools.api.models.common.LocalizedString name) { 127 this.name = name; 128 return this; 129 } 130 131 /** 132 * <p>Description of the Channel.</p> 133 * @param builder function to build the description value 134 * @return Builder 135 */ 136 137 public ChannelDraftBuilder description( 138 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedStringBuilder> builder) { 139 this.description = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()).build(); 140 return this; 141 } 142 143 /** 144 * <p>Description of the Channel.</p> 145 * @param builder function to build the description value 146 * @return Builder 147 */ 148 149 public ChannelDraftBuilder withDescription( 150 Function<com.commercetools.api.models.common.LocalizedStringBuilder, com.commercetools.api.models.common.LocalizedString> builder) { 151 this.description = builder.apply(com.commercetools.api.models.common.LocalizedStringBuilder.of()); 152 return this; 153 } 154 155 /** 156 * <p>Description of the Channel.</p> 157 * @param description value to be set 158 * @return Builder 159 */ 160 161 public ChannelDraftBuilder description( 162 @Nullable final com.commercetools.api.models.common.LocalizedString description) { 163 this.description = description; 164 return this; 165 } 166 167 /** 168 * <p>Address where the Channel is located.</p> 169 * @param builder function to build the address value 170 * @return Builder 171 */ 172 173 public ChannelDraftBuilder address( 174 Function<com.commercetools.api.models.common.BaseAddressBuilder, com.commercetools.api.models.common.BaseAddressBuilder> builder) { 175 this.address = builder.apply(com.commercetools.api.models.common.BaseAddressBuilder.of()).build(); 176 return this; 177 } 178 179 /** 180 * <p>Address where the Channel is located.</p> 181 * @param builder function to build the address value 182 * @return Builder 183 */ 184 185 public ChannelDraftBuilder withAddress( 186 Function<com.commercetools.api.models.common.BaseAddressBuilder, com.commercetools.api.models.common.BaseAddress> builder) { 187 this.address = builder.apply(com.commercetools.api.models.common.BaseAddressBuilder.of()); 188 return this; 189 } 190 191 /** 192 * <p>Address where the Channel is located.</p> 193 * @param address value to be set 194 * @return Builder 195 */ 196 197 public ChannelDraftBuilder address(@Nullable final com.commercetools.api.models.common.BaseAddress address) { 198 this.address = address; 199 return this; 200 } 201 202 /** 203 * <p>Custom fields defined for the Channel.</p> 204 * @param builder function to build the custom value 205 * @return Builder 206 */ 207 208 public ChannelDraftBuilder custom( 209 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraftBuilder> builder) { 210 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()).build(); 211 return this; 212 } 213 214 /** 215 * <p>Custom fields defined for the Channel.</p> 216 * @param builder function to build the custom value 217 * @return Builder 218 */ 219 220 public ChannelDraftBuilder withCustom( 221 Function<com.commercetools.api.models.type.CustomFieldsDraftBuilder, com.commercetools.api.models.type.CustomFieldsDraft> builder) { 222 this.custom = builder.apply(com.commercetools.api.models.type.CustomFieldsDraftBuilder.of()); 223 return this; 224 } 225 226 /** 227 * <p>Custom fields defined for the Channel.</p> 228 * @param custom value to be set 229 * @return Builder 230 */ 231 232 public ChannelDraftBuilder custom(@Nullable final com.commercetools.api.models.type.CustomFieldsDraft custom) { 233 this.custom = custom; 234 return this; 235 } 236 237 /** 238 * <p>GeoJSON geometry object encoding the geo location of the Channel. Currently, only the Point type is supported.</p> 239 * @param geoLocation value to be set 240 * @return Builder 241 */ 242 243 public ChannelDraftBuilder geoLocation(@Nullable final com.commercetools.api.models.common.GeoJson geoLocation) { 244 this.geoLocation = geoLocation; 245 return this; 246 } 247 248 /** 249 * <p>GeoJSON geometry object encoding the geo location of the Channel. Currently, only the Point type is supported.</p> 250 * @param builder function to build the geoLocation value 251 * @return Builder 252 */ 253 254 public ChannelDraftBuilder geoLocation( 255 Function<com.commercetools.api.models.common.GeoJsonBuilder, Builder<? extends com.commercetools.api.models.common.GeoJson>> builder) { 256 this.geoLocation = builder.apply(com.commercetools.api.models.common.GeoJsonBuilder.of()).build(); 257 return this; 258 } 259 260 /** 261 * <p>User-defined unique identifier for the Channel.</p> 262 * @return key 263 */ 264 265 public String getKey() { 266 return this.key; 267 } 268 269 /** 270 * <p>Roles of the Channel. Each channel must have at least one role. If not specified, then <code>InventorySupply</code> is assigned by default.</p> 271 * @return roles 272 */ 273 274 @Nullable 275 public java.util.List<com.commercetools.api.models.channel.ChannelRoleEnum> getRoles() { 276 return this.roles; 277 } 278 279 /** 280 * <p>Name of the Channel.</p> 281 * @return name 282 */ 283 284 @Nullable 285 public com.commercetools.api.models.common.LocalizedString getName() { 286 return this.name; 287 } 288 289 /** 290 * <p>Description of the Channel.</p> 291 * @return description 292 */ 293 294 @Nullable 295 public com.commercetools.api.models.common.LocalizedString getDescription() { 296 return this.description; 297 } 298 299 /** 300 * <p>Address where the Channel is located.</p> 301 * @return address 302 */ 303 304 @Nullable 305 public com.commercetools.api.models.common.BaseAddress getAddress() { 306 return this.address; 307 } 308 309 /** 310 * <p>Custom fields defined for the Channel.</p> 311 * @return custom 312 */ 313 314 @Nullable 315 public com.commercetools.api.models.type.CustomFieldsDraft getCustom() { 316 return this.custom; 317 } 318 319 /** 320 * <p>GeoJSON geometry object encoding the geo location of the Channel. Currently, only the Point type is supported.</p> 321 * @return geoLocation 322 */ 323 324 @Nullable 325 public com.commercetools.api.models.common.GeoJson getGeoLocation() { 326 return this.geoLocation; 327 } 328 329 /** 330 * builds ChannelDraft with checking for non-null required values 331 * @return ChannelDraft 332 */ 333 public ChannelDraft build() { 334 Objects.requireNonNull(key, ChannelDraft.class + ": key is missing"); 335 return new ChannelDraftImpl(key, roles, name, description, address, custom, geoLocation); 336 } 337 338 /** 339 * builds ChannelDraft without checking for non-null required values 340 * @return ChannelDraft 341 */ 342 public ChannelDraft buildUnchecked() { 343 return new ChannelDraftImpl(key, roles, name, description, address, custom, geoLocation); 344 } 345 346 /** 347 * factory method for an instance of ChannelDraftBuilder 348 * @return builder 349 */ 350 public static ChannelDraftBuilder of() { 351 return new ChannelDraftBuilder(); 352 } 353 354 /** 355 * create builder for ChannelDraft instance 356 * @param template instance with prefilled values for the builder 357 * @return builder 358 */ 359 public static ChannelDraftBuilder of(final ChannelDraft template) { 360 ChannelDraftBuilder builder = new ChannelDraftBuilder(); 361 builder.key = template.getKey(); 362 builder.roles = template.getRoles(); 363 builder.name = template.getName(); 364 builder.description = template.getDescription(); 365 builder.address = template.getAddress(); 366 builder.custom = template.getCustom(); 367 builder.geoLocation = template.getGeoLocation(); 368 return builder; 369 } 370 371}