001 002package com.commercetools.ml.models.similar_products; 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 * SimilarProductMetaBuilder 014 * <hr> 015 * Example to create an instance using the builder pattern 016 * <div class=code-example> 017 * <pre><code class='java'> 018 * SimilarProductMeta similarProductMeta = SimilarProductMeta.builder() 019 * .build() 020 * </code></pre> 021 * </div> 022 */ 023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 024public class SimilarProductMetaBuilder implements Builder<SimilarProductMeta> { 025 026 @Nullable 027 private com.commercetools.ml.models.common.LocalizedString name; 028 029 @Nullable 030 private com.commercetools.ml.models.common.LocalizedString description; 031 032 @Nullable 033 private com.commercetools.ml.models.common.Money price; 034 035 @Nullable 036 private Long variantCount; 037 038 /** 039 * <p>Localized product name used for similarity estimation.</p> 040 * @param builder function to build the name value 041 * @return Builder 042 */ 043 044 public SimilarProductMetaBuilder name( 045 Function<com.commercetools.ml.models.common.LocalizedStringBuilder, com.commercetools.ml.models.common.LocalizedStringBuilder> builder) { 046 this.name = builder.apply(com.commercetools.ml.models.common.LocalizedStringBuilder.of()).build(); 047 return this; 048 } 049 050 /** 051 * <p>Localized product name used for similarity estimation.</p> 052 * @param builder function to build the name value 053 * @return Builder 054 */ 055 056 public SimilarProductMetaBuilder withName( 057 Function<com.commercetools.ml.models.common.LocalizedStringBuilder, com.commercetools.ml.models.common.LocalizedString> builder) { 058 this.name = builder.apply(com.commercetools.ml.models.common.LocalizedStringBuilder.of()); 059 return this; 060 } 061 062 /** 063 * <p>Localized product name used for similarity estimation.</p> 064 * @param name value to be set 065 * @return Builder 066 */ 067 068 public SimilarProductMetaBuilder name(@Nullable final com.commercetools.ml.models.common.LocalizedString name) { 069 this.name = name; 070 return this; 071 } 072 073 /** 074 * <p>Localized product description used for similarity estimation.</p> 075 * @param builder function to build the description value 076 * @return Builder 077 */ 078 079 public SimilarProductMetaBuilder description( 080 Function<com.commercetools.ml.models.common.LocalizedStringBuilder, com.commercetools.ml.models.common.LocalizedStringBuilder> builder) { 081 this.description = builder.apply(com.commercetools.ml.models.common.LocalizedStringBuilder.of()).build(); 082 return this; 083 } 084 085 /** 086 * <p>Localized product description used for similarity estimation.</p> 087 * @param builder function to build the description value 088 * @return Builder 089 */ 090 091 public SimilarProductMetaBuilder withDescription( 092 Function<com.commercetools.ml.models.common.LocalizedStringBuilder, com.commercetools.ml.models.common.LocalizedString> builder) { 093 this.description = builder.apply(com.commercetools.ml.models.common.LocalizedStringBuilder.of()); 094 return this; 095 } 096 097 /** 098 * <p>Localized product description used for similarity estimation.</p> 099 * @param description value to be set 100 * @return Builder 101 */ 102 103 public SimilarProductMetaBuilder description( 104 @Nullable final com.commercetools.ml.models.common.LocalizedString description) { 105 this.description = description; 106 return this; 107 } 108 109 /** 110 * <p>The product price in cents using the currency defined in SimilarProductSearchRequest If multiple prices exist, the median value is taken as a representative amount.</p> 111 * @param builder function to build the price value 112 * @return Builder 113 */ 114 115 public SimilarProductMetaBuilder price( 116 Function<com.commercetools.ml.models.common.MoneyBuilder, com.commercetools.ml.models.common.MoneyBuilder> builder) { 117 this.price = builder.apply(com.commercetools.ml.models.common.MoneyBuilder.of()).build(); 118 return this; 119 } 120 121 /** 122 * <p>The product price in cents using the currency defined in SimilarProductSearchRequest If multiple prices exist, the median value is taken as a representative amount.</p> 123 * @param builder function to build the price value 124 * @return Builder 125 */ 126 127 public SimilarProductMetaBuilder withPrice( 128 Function<com.commercetools.ml.models.common.MoneyBuilder, com.commercetools.ml.models.common.Money> builder) { 129 this.price = builder.apply(com.commercetools.ml.models.common.MoneyBuilder.of()); 130 return this; 131 } 132 133 /** 134 * <p>The product price in cents using the currency defined in SimilarProductSearchRequest If multiple prices exist, the median value is taken as a representative amount.</p> 135 * @param price value to be set 136 * @return Builder 137 */ 138 139 public SimilarProductMetaBuilder price(@Nullable final com.commercetools.ml.models.common.Money price) { 140 this.price = price; 141 return this; 142 } 143 144 /** 145 * <p>Total number of variants associated with the product.</p> 146 * @param variantCount value to be set 147 * @return Builder 148 */ 149 150 public SimilarProductMetaBuilder variantCount(@Nullable final Long variantCount) { 151 this.variantCount = variantCount; 152 return this; 153 } 154 155 /** 156 * <p>Localized product name used for similarity estimation.</p> 157 * @return name 158 */ 159 160 @Nullable 161 public com.commercetools.ml.models.common.LocalizedString getName() { 162 return this.name; 163 } 164 165 /** 166 * <p>Localized product description used for similarity estimation.</p> 167 * @return description 168 */ 169 170 @Nullable 171 public com.commercetools.ml.models.common.LocalizedString getDescription() { 172 return this.description; 173 } 174 175 /** 176 * <p>The product price in cents using the currency defined in SimilarProductSearchRequest If multiple prices exist, the median value is taken as a representative amount.</p> 177 * @return price 178 */ 179 180 @Nullable 181 public com.commercetools.ml.models.common.Money getPrice() { 182 return this.price; 183 } 184 185 /** 186 * <p>Total number of variants associated with the product.</p> 187 * @return variantCount 188 */ 189 190 @Nullable 191 public Long getVariantCount() { 192 return this.variantCount; 193 } 194 195 /** 196 * builds SimilarProductMeta with checking for non-null required values 197 * @return SimilarProductMeta 198 */ 199 public SimilarProductMeta build() { 200 return new SimilarProductMetaImpl(name, description, price, variantCount); 201 } 202 203 /** 204 * builds SimilarProductMeta without checking for non-null required values 205 * @return SimilarProductMeta 206 */ 207 public SimilarProductMeta buildUnchecked() { 208 return new SimilarProductMetaImpl(name, description, price, variantCount); 209 } 210 211 /** 212 * factory method for an instance of SimilarProductMetaBuilder 213 * @return builder 214 */ 215 public static SimilarProductMetaBuilder of() { 216 return new SimilarProductMetaBuilder(); 217 } 218 219 /** 220 * create builder for SimilarProductMeta instance 221 * @param template instance with prefilled values for the builder 222 * @return builder 223 */ 224 public static SimilarProductMetaBuilder of(final SimilarProductMeta template) { 225 SimilarProductMetaBuilder builder = new SimilarProductMetaBuilder(); 226 builder.name = template.getName(); 227 builder.description = template.getDescription(); 228 builder.price = template.getPrice(); 229 builder.variantCount = template.getVariantCount(); 230 return builder; 231 } 232 233}