001 002package com.commercetools.ml.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.Valid; 010import javax.validation.constraints.NotNull; 011 012import com.fasterxml.jackson.annotation.*; 013import com.fasterxml.jackson.databind.annotation.*; 014 015import io.vrap.rmf.base.client.utils.Generated; 016 017/** 018 * <p>The product variant that contains the image.</p> 019 * 020 * <hr> 021 * Example to create an instance using the builder pattern 022 * <div class=code-example> 023 * <pre><code class='java'> 024 * ProductVariant productVariant = ProductVariant.builder() 025 * .product(productBuilder -> productBuilder) 026 * .staged(true) 027 * .variantId(0.3) 028 * .build() 029 * </code></pre> 030 * </div> 031 */ 032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 033@JsonDeserialize(as = ProductVariantImpl.class) 034public interface ProductVariant { 035 036 /** 037 * <p>The product that contains this variant.</p> 038 * @return product 039 */ 040 @NotNull 041 @Valid 042 @JsonProperty("product") 043 public ProductReference getProduct(); 044 045 /** 046 * <p>The state of the product variant.</p> 047 * @return staged 048 */ 049 @NotNull 050 @JsonProperty("staged") 051 public Boolean getStaged(); 052 053 /** 054 * <p>The id of the product variant.</p> 055 * @return variantId 056 */ 057 @NotNull 058 @JsonProperty("variantId") 059 public Integer getVariantId(); 060 061 /** 062 * <p>The product that contains this variant.</p> 063 * @param product value to be set 064 */ 065 066 public void setProduct(final ProductReference product); 067 068 /** 069 * <p>The state of the product variant.</p> 070 * @param staged value to be set 071 */ 072 073 public void setStaged(final Boolean staged); 074 075 /** 076 * <p>The id of the product variant.</p> 077 * @param variantId value to be set 078 */ 079 080 public void setVariantId(final Integer variantId); 081 082 /** 083 * factory method 084 * @return instance of ProductVariant 085 */ 086 public static ProductVariant of() { 087 return new ProductVariantImpl(); 088 } 089 090 /** 091 * factory method to create a shallow copy ProductVariant 092 * @param template instance to be copied 093 * @return copy instance 094 */ 095 public static ProductVariant of(final ProductVariant template) { 096 ProductVariantImpl instance = new ProductVariantImpl(); 097 instance.setProduct(template.getProduct()); 098 instance.setStaged(template.getStaged()); 099 instance.setVariantId(template.getVariantId()); 100 return instance; 101 } 102 103 /** 104 * factory method to create a deep copy of ProductVariant 105 * @param template instance to be copied 106 * @return copy instance 107 */ 108 @Nullable 109 public static ProductVariant deepCopy(@Nullable final ProductVariant template) { 110 if (template == null) { 111 return null; 112 } 113 ProductVariantImpl instance = new ProductVariantImpl(); 114 instance.setProduct(com.commercetools.ml.models.common.ProductReference.deepCopy(template.getProduct())); 115 instance.setStaged(template.getStaged()); 116 instance.setVariantId(template.getVariantId()); 117 return instance; 118 } 119 120 /** 121 * builder factory method for ProductVariant 122 * @return builder 123 */ 124 public static ProductVariantBuilder builder() { 125 return ProductVariantBuilder.of(); 126 } 127 128 /** 129 * create builder for ProductVariant instance 130 * @param template instance with prefilled values for the builder 131 * @return builder 132 */ 133 public static ProductVariantBuilder builder(final ProductVariant template) { 134 return ProductVariantBuilder.of(template); 135 } 136 137 /** 138 * accessor map function 139 * @param <T> mapped type 140 * @param helper function to map the object 141 * @return mapped value 142 */ 143 default <T> T withProductVariant(Function<ProductVariant, T> helper) { 144 return helper.apply(this); 145 } 146 147 /** 148 * gives a TypeReference for usage with Jackson DataBind 149 * @return TypeReference 150 */ 151 public static com.fasterxml.jackson.core.type.TypeReference<ProductVariant> typeReference() { 152 return new com.fasterxml.jackson.core.type.TypeReference<ProductVariant>() { 153 @Override 154 public String toString() { 155 return "TypeReference<ProductVariant>"; 156 } 157 }; 158 } 159}