001 002package com.commercetools.api.models.product_discount; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007import java.util.stream.Collectors; 008 009import javax.annotation.Nullable; 010import javax.validation.Valid; 011import javax.validation.constraints.NotNull; 012 013import com.fasterxml.jackson.annotation.*; 014import com.fasterxml.jackson.databind.annotation.*; 015 016import io.vrap.rmf.base.client.utils.Generated; 017 018/** 019 * ProductDiscountUpdate 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * ProductDiscountUpdate productDiscountUpdate = ProductDiscountUpdate.builder() 026 * .version(0.3) 027 * .plusActions(actionsBuilder -> actionsBuilder) 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 = ProductDiscountUpdateImpl.class) 034public interface ProductDiscountUpdate extends 035 com.commercetools.api.models.ResourceUpdate<ProductDiscountUpdate, ProductDiscountUpdateAction, ProductDiscountUpdateBuilder> { 036 037 /** 038 * <p>Expected version of the ProductDiscount on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p> 039 * @return version 040 */ 041 @NotNull 042 @JsonProperty("version") 043 public Long getVersion(); 044 045 /** 046 * <p>Update actions to be performed on the ProductDiscount.</p> 047 * @return actions 048 */ 049 @NotNull 050 @Valid 051 @JsonProperty("actions") 052 public List<ProductDiscountUpdateAction> getActions(); 053 054 /** 055 * <p>Expected version of the ProductDiscount on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error is returned.</p> 056 * @param version value to be set 057 */ 058 059 public void setVersion(final Long version); 060 061 /** 062 * <p>Update actions to be performed on the ProductDiscount.</p> 063 * @param actions values to be set 064 */ 065 066 @JsonIgnore 067 public void setActions(final ProductDiscountUpdateAction... actions); 068 069 /** 070 * <p>Update actions to be performed on the ProductDiscount.</p> 071 * @param actions values to be set 072 */ 073 074 public void setActions(final List<ProductDiscountUpdateAction> actions); 075 076 /** 077 * factory method 078 * @return instance of ProductDiscountUpdate 079 */ 080 public static ProductDiscountUpdate of() { 081 return new ProductDiscountUpdateImpl(); 082 } 083 084 /** 085 * factory method to create a shallow copy ProductDiscountUpdate 086 * @param template instance to be copied 087 * @return copy instance 088 */ 089 public static ProductDiscountUpdate of(final ProductDiscountUpdate template) { 090 ProductDiscountUpdateImpl instance = new ProductDiscountUpdateImpl(); 091 instance.setVersion(template.getVersion()); 092 instance.setActions(template.getActions()); 093 return instance; 094 } 095 096 /** 097 * factory method to create a deep copy of ProductDiscountUpdate 098 * @param template instance to be copied 099 * @return copy instance 100 */ 101 @Nullable 102 public static ProductDiscountUpdate deepCopy(@Nullable final ProductDiscountUpdate template) { 103 if (template == null) { 104 return null; 105 } 106 ProductDiscountUpdateImpl instance = new ProductDiscountUpdateImpl(); 107 instance.setVersion(template.getVersion()); 108 instance.setActions(Optional.ofNullable(template.getActions()) 109 .map(t -> t.stream() 110 .map(com.commercetools.api.models.product_discount.ProductDiscountUpdateAction::deepCopy) 111 .collect(Collectors.toList())) 112 .orElse(null)); 113 return instance; 114 } 115 116 /** 117 * builder factory method for ProductDiscountUpdate 118 * @return builder 119 */ 120 public static ProductDiscountUpdateBuilder builder() { 121 return ProductDiscountUpdateBuilder.of(); 122 } 123 124 /** 125 * create builder for ProductDiscountUpdate instance 126 * @param template instance with prefilled values for the builder 127 * @return builder 128 */ 129 public static ProductDiscountUpdateBuilder builder(final ProductDiscountUpdate template) { 130 return ProductDiscountUpdateBuilder.of(template); 131 } 132 133 /** 134 * accessor map function 135 * @param <T> mapped type 136 * @param helper function to map the object 137 * @return mapped value 138 */ 139 default <T> T withProductDiscountUpdate(Function<ProductDiscountUpdate, T> helper) { 140 return helper.apply(this); 141 } 142 143 /** 144 * gives a TypeReference for usage with Jackson DataBind 145 * @return TypeReference 146 */ 147 public static com.fasterxml.jackson.core.type.TypeReference<ProductDiscountUpdate> typeReference() { 148 return new com.fasterxml.jackson.core.type.TypeReference<ProductDiscountUpdate>() { 149 @Override 150 public String toString() { 151 return "TypeReference<ProductDiscountUpdate>"; 152 } 153 }; 154 } 155}