001 002package com.commercetools.api.models.product_selection; 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 * ProductSelectionSetVariantSelectionActionBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * ProductSelectionSetVariantSelectionAction productSelectionSetVariantSelectionAction = ProductSelectionSetVariantSelectionAction.builder() 019 * .product(productBuilder -> productBuilder) 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 ProductSelectionSetVariantSelectionActionBuilder 026 implements Builder<ProductSelectionSetVariantSelectionAction> { 027 028 private com.commercetools.api.models.product.ProductResourceIdentifier product; 029 030 @Nullable 031 private com.commercetools.api.models.product_selection.ProductVariantSelection variantSelection; 032 033 /** 034 * <p>ResourceIdentifier of the Product</p> 035 * @param builder function to build the product value 036 * @return Builder 037 */ 038 039 public ProductSelectionSetVariantSelectionActionBuilder product( 040 Function<com.commercetools.api.models.product.ProductResourceIdentifierBuilder, com.commercetools.api.models.product.ProductResourceIdentifierBuilder> builder) { 041 this.product = builder.apply(com.commercetools.api.models.product.ProductResourceIdentifierBuilder.of()) 042 .build(); 043 return this; 044 } 045 046 /** 047 * <p>ResourceIdentifier of the Product</p> 048 * @param builder function to build the product value 049 * @return Builder 050 */ 051 052 public ProductSelectionSetVariantSelectionActionBuilder withProduct( 053 Function<com.commercetools.api.models.product.ProductResourceIdentifierBuilder, com.commercetools.api.models.product.ProductResourceIdentifier> builder) { 054 this.product = builder.apply(com.commercetools.api.models.product.ProductResourceIdentifierBuilder.of()); 055 return this; 056 } 057 058 /** 059 * <p>ResourceIdentifier of the Product</p> 060 * @param product value to be set 061 * @return Builder 062 */ 063 064 public ProductSelectionSetVariantSelectionActionBuilder product( 065 final com.commercetools.api.models.product.ProductResourceIdentifier product) { 066 this.product = product; 067 return this; 068 } 069 070 /** 071 * <p>Determines which Variants of the previously added Product are to be included in, or excluded from, the Product Selection. Leave it empty to unset an existing Variant Selection.</p> 072 * @param variantSelection value to be set 073 * @return Builder 074 */ 075 076 public ProductSelectionSetVariantSelectionActionBuilder variantSelection( 077 @Nullable final com.commercetools.api.models.product_selection.ProductVariantSelection variantSelection) { 078 this.variantSelection = variantSelection; 079 return this; 080 } 081 082 /** 083 * <p>Determines which Variants of the previously added Product are to be included in, or excluded from, the Product Selection. Leave it empty to unset an existing Variant Selection.</p> 084 * @param builder function to build the variantSelection value 085 * @return Builder 086 */ 087 088 public ProductSelectionSetVariantSelectionActionBuilder variantSelection( 089 Function<com.commercetools.api.models.product_selection.ProductVariantSelectionBuilder, Builder<? extends com.commercetools.api.models.product_selection.ProductVariantSelection>> builder) { 090 this.variantSelection = builder 091 .apply(com.commercetools.api.models.product_selection.ProductVariantSelectionBuilder.of()) 092 .build(); 093 return this; 094 } 095 096 /** 097 * <p>ResourceIdentifier of the Product</p> 098 * @return product 099 */ 100 101 public com.commercetools.api.models.product.ProductResourceIdentifier getProduct() { 102 return this.product; 103 } 104 105 /** 106 * <p>Determines which Variants of the previously added Product are to be included in, or excluded from, the Product Selection. Leave it empty to unset an existing Variant Selection.</p> 107 * @return variantSelection 108 */ 109 110 @Nullable 111 public com.commercetools.api.models.product_selection.ProductVariantSelection getVariantSelection() { 112 return this.variantSelection; 113 } 114 115 /** 116 * builds ProductSelectionSetVariantSelectionAction with checking for non-null required values 117 * @return ProductSelectionSetVariantSelectionAction 118 */ 119 public ProductSelectionSetVariantSelectionAction build() { 120 Objects.requireNonNull(product, ProductSelectionSetVariantSelectionAction.class + ": product is missing"); 121 return new ProductSelectionSetVariantSelectionActionImpl(product, variantSelection); 122 } 123 124 /** 125 * builds ProductSelectionSetVariantSelectionAction without checking for non-null required values 126 * @return ProductSelectionSetVariantSelectionAction 127 */ 128 public ProductSelectionSetVariantSelectionAction buildUnchecked() { 129 return new ProductSelectionSetVariantSelectionActionImpl(product, variantSelection); 130 } 131 132 /** 133 * factory method for an instance of ProductSelectionSetVariantSelectionActionBuilder 134 * @return builder 135 */ 136 public static ProductSelectionSetVariantSelectionActionBuilder of() { 137 return new ProductSelectionSetVariantSelectionActionBuilder(); 138 } 139 140 /** 141 * create builder for ProductSelectionSetVariantSelectionAction instance 142 * @param template instance with prefilled values for the builder 143 * @return builder 144 */ 145 public static ProductSelectionSetVariantSelectionActionBuilder of( 146 final ProductSelectionSetVariantSelectionAction template) { 147 ProductSelectionSetVariantSelectionActionBuilder builder = new ProductSelectionSetVariantSelectionActionBuilder(); 148 builder.product = template.getProduct(); 149 builder.variantSelection = template.getVariantSelection(); 150 return builder; 151 } 152 153}