001 002package com.commercetools.api.models.product; 003 004import java.time.*; 005import java.time.ZonedDateTime; 006import java.util.*; 007import java.util.function.Function; 008import java.util.stream.Collectors; 009 010import javax.annotation.Nullable; 011import javax.validation.Valid; 012import javax.validation.constraints.NotNull; 013 014import com.commercetools.api.models.category.CategoryReference; 015import com.commercetools.api.models.common.BaseResource; 016import com.commercetools.api.models.common.LocalizedString; 017import com.commercetools.api.models.product_type.ProductTypeReference; 018import com.commercetools.api.models.review.ReviewRatingStatistics; 019import com.commercetools.api.models.state.StateReference; 020import com.commercetools.api.models.tax_category.TaxCategoryReference; 021import com.fasterxml.jackson.annotation.*; 022import com.fasterxml.jackson.databind.annotation.*; 023 024import io.vrap.rmf.base.client.utils.Generated; 025 026/** 027 * ProductProjection 028 * 029 * <hr> 030 * Example to create an instance using the builder pattern 031 * <div class=code-example> 032 * <pre><code class='java'> 033 * ProductProjection productProjection = ProductProjection.builder() 034 * .id("{id}") 035 * .version(0.3) 036 * .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z")) 037 * .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z")) 038 * .productType(productTypeBuilder -> productTypeBuilder) 039 * .name(nameBuilder -> nameBuilder) 040 * .slug(slugBuilder -> slugBuilder) 041 * .plusCategories(categoriesBuilder -> categoriesBuilder) 042 * .masterVariant(masterVariantBuilder -> masterVariantBuilder) 043 * .plusVariants(variantsBuilder -> variantsBuilder) 044 * .build() 045 * </code></pre> 046 * </div> 047 */ 048@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 049@JsonDeserialize(as = ProductProjectionImpl.class) 050public interface ProductProjection extends BaseResource, ProductDataLike, ProductProjectionMixin, 051 com.commercetools.api.models.DomainResource<ProductProjection>, com.commercetools.api.models.WithKey { 052 053 /** 054 * <p>Unique identifier of the Product.</p> 055 * @return id 056 */ 057 @NotNull 058 @JsonProperty("id") 059 public String getId(); 060 061 /** 062 * <p>Current version of the Product.</p> 063 * @return version 064 */ 065 @NotNull 066 @JsonProperty("version") 067 public Long getVersion(); 068 069 /** 070 * <p>User-defined unique identifier of the Product.</p> 071 * @return key 072 */ 073 074 @JsonProperty("key") 075 public String getKey(); 076 077 /** 078 * <p>Date and time (UTC) the ProductProjection was initially created.</p> 079 * @return createdAt 080 */ 081 @NotNull 082 @JsonProperty("createdAt") 083 public ZonedDateTime getCreatedAt(); 084 085 /** 086 * <p>Date and time (UTC) the ProductProjection was last updated.</p> 087 * @return lastModifiedAt 088 */ 089 @NotNull 090 @JsonProperty("lastModifiedAt") 091 public ZonedDateTime getLastModifiedAt(); 092 093 /** 094 * <p>The ProductType defining the Attributes of the Product.</p> 095 * @return productType 096 */ 097 @NotNull 098 @Valid 099 @JsonProperty("productType") 100 public ProductTypeReference getProductType(); 101 102 /** 103 * <p>Name of the Product.</p> 104 * @return name 105 */ 106 @NotNull 107 @Valid 108 @JsonProperty("name") 109 public LocalizedString getName(); 110 111 /** 112 * <p>Description of the Product.</p> 113 * @return description 114 */ 115 @Valid 116 @JsonProperty("description") 117 public LocalizedString getDescription(); 118 119 /** 120 * <p>User-defined identifier used in a deep-link URL for the Product. Must be unique across a Project, but can be the same for Products in different locales. Matches the pattern <code>[a-zA-Z0-9_\-]{2,256}</code>. For good performance, indexes are provided for the first 15 <code>languages</code> set in the Project.</p> 121 * @return slug 122 */ 123 @NotNull 124 @Valid 125 @JsonProperty("slug") 126 public LocalizedString getSlug(); 127 128 /** 129 * <p>Categories assigned to the Product.</p> 130 * @return categories 131 */ 132 @NotNull 133 @Valid 134 @JsonProperty("categories") 135 public List<CategoryReference> getCategories(); 136 137 /** 138 * <p>Order of Product in Categories.</p> 139 * @return categoryOrderHints 140 */ 141 @Valid 142 @JsonProperty("categoryOrderHints") 143 public CategoryOrderHints getCategoryOrderHints(); 144 145 /** 146 * <p>Title of the Product displayed in search results.</p> 147 * @return metaTitle 148 */ 149 @Valid 150 @JsonProperty("metaTitle") 151 public LocalizedString getMetaTitle(); 152 153 /** 154 * <p>Description of the Product displayed in search results below the meta title.</p> 155 * @return metaDescription 156 */ 157 @Valid 158 @JsonProperty("metaDescription") 159 public LocalizedString getMetaDescription(); 160 161 /** 162 * <p>Keywords that give additional information about the Product to search engines.</p> 163 * @return metaKeywords 164 */ 165 @Valid 166 @JsonProperty("metaKeywords") 167 public LocalizedString getMetaKeywords(); 168 169 /** 170 * <p>Used by Product Suggestions, but is also considered for a full text search.</p> 171 * @return searchKeywords 172 */ 173 @Valid 174 @JsonProperty("searchKeywords") 175 public SearchKeywords getSearchKeywords(); 176 177 /** 178 * <p><code>true</code> if the staged data is different from the current data.</p> 179 * @return hasStagedChanges 180 */ 181 182 @JsonProperty("hasStagedChanges") 183 public Boolean getHasStagedChanges(); 184 185 /** 186 * <p><code>true</code> if the Product is published.</p> 187 * @return published 188 */ 189 190 @JsonProperty("published") 191 public Boolean getPublished(); 192 193 /** 194 * <p>The Master Variant of the Product.</p> 195 * @return masterVariant 196 */ 197 @NotNull 198 @Valid 199 @JsonProperty("masterVariant") 200 public ProductVariant getMasterVariant(); 201 202 /** 203 * <p>Additional Product Variants.</p> 204 * @return variants 205 */ 206 @NotNull 207 @Valid 208 @JsonProperty("variants") 209 public List<ProductVariant> getVariants(); 210 211 /** 212 * <p>The TaxCategory of the Product.</p> 213 * @return taxCategory 214 */ 215 @Valid 216 @JsonProperty("taxCategory") 217 public TaxCategoryReference getTaxCategory(); 218 219 /** 220 * <p>State of the Product.</p> 221 * @return state 222 */ 223 @Valid 224 @JsonProperty("state") 225 public StateReference getState(); 226 227 /** 228 * <p>Review statistics of the Product.</p> 229 * @return reviewRatingStatistics 230 */ 231 @Valid 232 @JsonProperty("reviewRatingStatistics") 233 public ReviewRatingStatistics getReviewRatingStatistics(); 234 235 /** 236 * <p>Indicates whether the Prices of the Product Projection are embedded or standalone. Projecting Prices only works with <code>Embedded</code>, there is currently no support for <code>Standalone</code>.</p> 237 * @return priceMode 238 */ 239 240 @JsonProperty("priceMode") 241 public ProductPriceModeEnum getPriceMode(); 242 243 /** 244 * <p>Unique identifier of the Product.</p> 245 * @param id value to be set 246 */ 247 248 public void setId(final String id); 249 250 /** 251 * <p>Current version of the Product.</p> 252 * @param version value to be set 253 */ 254 255 public void setVersion(final Long version); 256 257 /** 258 * <p>User-defined unique identifier of the Product.</p> 259 * @param key value to be set 260 */ 261 262 public void setKey(final String key); 263 264 /** 265 * <p>Date and time (UTC) the ProductProjection was initially created.</p> 266 * @param createdAt value to be set 267 */ 268 269 public void setCreatedAt(final ZonedDateTime createdAt); 270 271 /** 272 * <p>Date and time (UTC) the ProductProjection was last updated.</p> 273 * @param lastModifiedAt value to be set 274 */ 275 276 public void setLastModifiedAt(final ZonedDateTime lastModifiedAt); 277 278 /** 279 * <p>The ProductType defining the Attributes of the Product.</p> 280 * @param productType value to be set 281 */ 282 283 public void setProductType(final ProductTypeReference productType); 284 285 /** 286 * <p>Name of the Product.</p> 287 * @param name value to be set 288 */ 289 290 public void setName(final LocalizedString name); 291 292 /** 293 * <p>Description of the Product.</p> 294 * @param description value to be set 295 */ 296 297 public void setDescription(final LocalizedString description); 298 299 /** 300 * <p>User-defined identifier used in a deep-link URL for the Product. Must be unique across a Project, but can be the same for Products in different locales. Matches the pattern <code>[a-zA-Z0-9_\-]{2,256}</code>. For good performance, indexes are provided for the first 15 <code>languages</code> set in the Project.</p> 301 * @param slug value to be set 302 */ 303 304 public void setSlug(final LocalizedString slug); 305 306 /** 307 * <p>Categories assigned to the Product.</p> 308 * @param categories values to be set 309 */ 310 311 @JsonIgnore 312 public void setCategories(final CategoryReference... categories); 313 314 /** 315 * <p>Categories assigned to the Product.</p> 316 * @param categories values to be set 317 */ 318 319 public void setCategories(final List<CategoryReference> categories); 320 321 /** 322 * <p>Order of Product in Categories.</p> 323 * @param categoryOrderHints value to be set 324 */ 325 326 public void setCategoryOrderHints(final CategoryOrderHints categoryOrderHints); 327 328 /** 329 * <p>Title of the Product displayed in search results.</p> 330 * @param metaTitle value to be set 331 */ 332 333 public void setMetaTitle(final LocalizedString metaTitle); 334 335 /** 336 * <p>Description of the Product displayed in search results below the meta title.</p> 337 * @param metaDescription value to be set 338 */ 339 340 public void setMetaDescription(final LocalizedString metaDescription); 341 342 /** 343 * <p>Keywords that give additional information about the Product to search engines.</p> 344 * @param metaKeywords value to be set 345 */ 346 347 public void setMetaKeywords(final LocalizedString metaKeywords); 348 349 /** 350 * <p>Used by Product Suggestions, but is also considered for a full text search.</p> 351 * @param searchKeywords value to be set 352 */ 353 354 public void setSearchKeywords(final SearchKeywords searchKeywords); 355 356 /** 357 * <p><code>true</code> if the staged data is different from the current data.</p> 358 * @param hasStagedChanges value to be set 359 */ 360 361 public void setHasStagedChanges(final Boolean hasStagedChanges); 362 363 /** 364 * <p><code>true</code> if the Product is published.</p> 365 * @param published value to be set 366 */ 367 368 public void setPublished(final Boolean published); 369 370 /** 371 * <p>The Master Variant of the Product.</p> 372 * @param masterVariant value to be set 373 */ 374 375 public void setMasterVariant(final ProductVariant masterVariant); 376 377 /** 378 * <p>Additional Product Variants.</p> 379 * @param variants values to be set 380 */ 381 382 @JsonIgnore 383 public void setVariants(final ProductVariant... variants); 384 385 /** 386 * <p>Additional Product Variants.</p> 387 * @param variants values to be set 388 */ 389 390 public void setVariants(final List<ProductVariant> variants); 391 392 /** 393 * <p>The TaxCategory of the Product.</p> 394 * @param taxCategory value to be set 395 */ 396 397 public void setTaxCategory(final TaxCategoryReference taxCategory); 398 399 /** 400 * <p>State of the Product.</p> 401 * @param state value to be set 402 */ 403 404 public void setState(final StateReference state); 405 406 /** 407 * <p>Review statistics of the Product.</p> 408 * @param reviewRatingStatistics value to be set 409 */ 410 411 public void setReviewRatingStatistics(final ReviewRatingStatistics reviewRatingStatistics); 412 413 /** 414 * <p>Indicates whether the Prices of the Product Projection are embedded or standalone. Projecting Prices only works with <code>Embedded</code>, there is currently no support for <code>Standalone</code>.</p> 415 * @param priceMode value to be set 416 */ 417 418 public void setPriceMode(final ProductPriceModeEnum priceMode); 419 420 /** 421 * factory method 422 * @return instance of ProductProjection 423 */ 424 public static ProductProjection of() { 425 return new ProductProjectionImpl(); 426 } 427 428 /** 429 * factory method to create a shallow copy ProductProjection 430 * @param template instance to be copied 431 * @return copy instance 432 */ 433 public static ProductProjection of(final ProductProjection template) { 434 ProductProjectionImpl instance = new ProductProjectionImpl(); 435 instance.setId(template.getId()); 436 instance.setVersion(template.getVersion()); 437 instance.setCreatedAt(template.getCreatedAt()); 438 instance.setLastModifiedAt(template.getLastModifiedAt()); 439 instance.setKey(template.getKey()); 440 instance.setProductType(template.getProductType()); 441 instance.setName(template.getName()); 442 instance.setDescription(template.getDescription()); 443 instance.setSlug(template.getSlug()); 444 instance.setCategories(template.getCategories()); 445 instance.setCategoryOrderHints(template.getCategoryOrderHints()); 446 instance.setMetaTitle(template.getMetaTitle()); 447 instance.setMetaDescription(template.getMetaDescription()); 448 instance.setMetaKeywords(template.getMetaKeywords()); 449 instance.setSearchKeywords(template.getSearchKeywords()); 450 instance.setHasStagedChanges(template.getHasStagedChanges()); 451 instance.setPublished(template.getPublished()); 452 instance.setMasterVariant(template.getMasterVariant()); 453 instance.setVariants(template.getVariants()); 454 instance.setTaxCategory(template.getTaxCategory()); 455 instance.setState(template.getState()); 456 instance.setReviewRatingStatistics(template.getReviewRatingStatistics()); 457 instance.setPriceMode(template.getPriceMode()); 458 return instance; 459 } 460 461 /** 462 * factory method to create a deep copy of ProductProjection 463 * @param template instance to be copied 464 * @return copy instance 465 */ 466 @Nullable 467 public static ProductProjection deepCopy(@Nullable final ProductProjection template) { 468 if (template == null) { 469 return null; 470 } 471 ProductProjectionImpl instance = new ProductProjectionImpl(); 472 instance.setId(template.getId()); 473 instance.setVersion(template.getVersion()); 474 instance.setCreatedAt(template.getCreatedAt()); 475 instance.setLastModifiedAt(template.getLastModifiedAt()); 476 instance.setKey(template.getKey()); 477 instance.setProductType( 478 com.commercetools.api.models.product_type.ProductTypeReference.deepCopy(template.getProductType())); 479 instance.setName(com.commercetools.api.models.common.LocalizedString.deepCopy(template.getName())); 480 instance.setDescription( 481 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getDescription())); 482 instance.setSlug(com.commercetools.api.models.common.LocalizedString.deepCopy(template.getSlug())); 483 instance.setCategories(Optional.ofNullable(template.getCategories()) 484 .map(t -> t.stream() 485 .map(com.commercetools.api.models.category.CategoryReference::deepCopy) 486 .collect(Collectors.toList())) 487 .orElse(null)); 488 instance.setCategoryOrderHints( 489 com.commercetools.api.models.product.CategoryOrderHints.deepCopy(template.getCategoryOrderHints())); 490 instance.setMetaTitle(com.commercetools.api.models.common.LocalizedString.deepCopy(template.getMetaTitle())); 491 instance.setMetaDescription( 492 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getMetaDescription())); 493 instance.setMetaKeywords( 494 com.commercetools.api.models.common.LocalizedString.deepCopy(template.getMetaKeywords())); 495 instance.setSearchKeywords( 496 com.commercetools.api.models.product.SearchKeywords.deepCopy(template.getSearchKeywords())); 497 instance.setHasStagedChanges(template.getHasStagedChanges()); 498 instance.setPublished(template.getPublished()); 499 instance.setMasterVariant( 500 com.commercetools.api.models.product.ProductVariant.deepCopy(template.getMasterVariant())); 501 instance.setVariants(Optional.ofNullable(template.getVariants()) 502 .map(t -> t.stream() 503 .map(com.commercetools.api.models.product.ProductVariant::deepCopy) 504 .collect(Collectors.toList())) 505 .orElse(null)); 506 instance.setTaxCategory( 507 com.commercetools.api.models.tax_category.TaxCategoryReference.deepCopy(template.getTaxCategory())); 508 instance.setState(com.commercetools.api.models.state.StateReference.deepCopy(template.getState())); 509 instance.setReviewRatingStatistics( 510 com.commercetools.api.models.review.ReviewRatingStatistics.deepCopy(template.getReviewRatingStatistics())); 511 instance.setPriceMode(template.getPriceMode()); 512 return instance; 513 } 514 515 /** 516 * builder factory method for ProductProjection 517 * @return builder 518 */ 519 public static ProductProjectionBuilder builder() { 520 return ProductProjectionBuilder.of(); 521 } 522 523 /** 524 * create builder for ProductProjection instance 525 * @param template instance with prefilled values for the builder 526 * @return builder 527 */ 528 public static ProductProjectionBuilder builder(final ProductProjection template) { 529 return ProductProjectionBuilder.of(template); 530 } 531 532 /** 533 * accessor map function 534 * @param <T> mapped type 535 * @param helper function to map the object 536 * @return mapped value 537 */ 538 default <T> T withProductProjection(Function<ProductProjection, T> helper) { 539 return helper.apply(this); 540 } 541 542 /** 543 * gives a TypeReference for usage with Jackson DataBind 544 * @return TypeReference 545 */ 546 public static com.fasterxml.jackson.core.type.TypeReference<ProductProjection> typeReference() { 547 return new com.fasterxml.jackson.core.type.TypeReference<ProductProjection>() { 548 @Override 549 public String toString() { 550 return "TypeReference<ProductProjection>"; 551 } 552 }; 553 } 554}