001 002package com.commercetools.api.models.common; 003 004import java.time.*; 005import java.time.ZonedDateTime; 006import java.util.*; 007import java.util.function.Function; 008 009import javax.annotation.Nullable; 010import javax.validation.Valid; 011import javax.validation.constraints.NotNull; 012 013import com.commercetools.api.models.channel.ChannelReference; 014import com.commercetools.api.models.customer_group.CustomerGroupReference; 015import com.commercetools.api.models.type.CustomFields; 016import com.fasterxml.jackson.annotation.*; 017import com.fasterxml.jackson.databind.annotation.*; 018 019import io.vrap.rmf.base.client.utils.Generated; 020 021/** 022 * <p>Scoped Price is contained in a ProductVariant which is returned in response to a Product Projection Search request when Scoped Price Search is used.</p> 023 * 024 * <hr> 025 * Example to create an instance using the builder pattern 026 * <div class=code-example> 027 * <pre><code class='java'> 028 * ScopedPrice scopedPrice = ScopedPrice.builder() 029 * .id("{id}") 030 * .value(valueBuilder -> valueBuilder) 031 * .currentValue(currentValueBuilder -> currentValueBuilder) 032 * .build() 033 * </code></pre> 034 * </div> 035 */ 036@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 037@JsonDeserialize(as = ScopedPriceImpl.class) 038public interface ScopedPrice extends com.commercetools.api.models.Customizable<ScopedPrice> { 039 040 /** 041 * <p>Platform-generated unique identifier of the Price.</p> 042 * @return id 043 */ 044 @NotNull 045 @JsonProperty("id") 046 public String getId(); 047 048 /** 049 * <p>Original value of the Price.</p> 050 * @return value 051 */ 052 @NotNull 053 @Valid 054 @JsonProperty("value") 055 public TypedMoney getValue(); 056 057 /** 058 * <p>If available, either the original price <code>value</code> or <code>discounted</code> value.</p> 059 * @return currentValue 060 */ 061 @NotNull 062 @Valid 063 @JsonProperty("currentValue") 064 public TypedMoney getCurrentValue(); 065 066 /** 067 * <p>Country code of the geographic location.</p> 068 * @return country 069 */ 070 071 @JsonProperty("country") 072 public String getCountry(); 073 074 /** 075 * <p>Reference to a CustomerGroup.</p> 076 * @return customerGroup 077 */ 078 @Valid 079 @JsonProperty("customerGroup") 080 public CustomerGroupReference getCustomerGroup(); 081 082 /** 083 * <p>Reference to a Channel.</p> 084 * @return channel 085 */ 086 @Valid 087 @JsonProperty("channel") 088 public ChannelReference getChannel(); 089 090 /** 091 * <p>Date and time from which the Price is valid.</p> 092 * @return validFrom 093 */ 094 095 @JsonProperty("validFrom") 096 public ZonedDateTime getValidFrom(); 097 098 /** 099 * <p>Date and time until which the Price is valid.</p> 100 * @return validUntil 101 */ 102 103 @JsonProperty("validUntil") 104 public ZonedDateTime getValidUntil(); 105 106 /** 107 * <p>Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.</p> 108 * <p>When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.</p> 109 * @return discounted 110 */ 111 @Valid 112 @JsonProperty("discounted") 113 public DiscountedPrice getDiscounted(); 114 115 /** 116 * <p>Custom Fields for the Price.</p> 117 * @return custom 118 */ 119 @Valid 120 @JsonProperty("custom") 121 public CustomFields getCustom(); 122 123 /** 124 * <p>Platform-generated unique identifier of the Price.</p> 125 * @param id value to be set 126 */ 127 128 public void setId(final String id); 129 130 /** 131 * <p>Original value of the Price.</p> 132 * @param value value to be set 133 */ 134 135 public void setValue(final TypedMoney value); 136 137 /** 138 * <p>If available, either the original price <code>value</code> or <code>discounted</code> value.</p> 139 * @param currentValue value to be set 140 */ 141 142 public void setCurrentValue(final TypedMoney currentValue); 143 144 /** 145 * <p>Country code of the geographic location.</p> 146 * @param country value to be set 147 */ 148 149 public void setCountry(final String country); 150 151 /** 152 * <p>Reference to a CustomerGroup.</p> 153 * @param customerGroup value to be set 154 */ 155 156 public void setCustomerGroup(final CustomerGroupReference customerGroup); 157 158 /** 159 * <p>Reference to a Channel.</p> 160 * @param channel value to be set 161 */ 162 163 public void setChannel(final ChannelReference channel); 164 165 /** 166 * <p>Date and time from which the Price is valid.</p> 167 * @param validFrom value to be set 168 */ 169 170 public void setValidFrom(final ZonedDateTime validFrom); 171 172 /** 173 * <p>Date and time until which the Price is valid.</p> 174 * @param validUntil value to be set 175 */ 176 177 public void setValidUntil(final ZonedDateTime validUntil); 178 179 /** 180 * <p>Is set when a matching ProductDiscount exists. If set, the Cart uses the discounted value for the Cart Price calculation.</p> 181 * <p>When a relative Product Discount is applied and the fractional part of the discounted Price is 0.5, the discounted Price is rounded half down in favor of the Customer.</p> 182 * @param discounted value to be set 183 */ 184 185 public void setDiscounted(final DiscountedPrice discounted); 186 187 /** 188 * <p>Custom Fields for the Price.</p> 189 * @param custom value to be set 190 */ 191 192 public void setCustom(final CustomFields custom); 193 194 /** 195 * factory method 196 * @return instance of ScopedPrice 197 */ 198 public static ScopedPrice of() { 199 return new ScopedPriceImpl(); 200 } 201 202 /** 203 * factory method to create a shallow copy ScopedPrice 204 * @param template instance to be copied 205 * @return copy instance 206 */ 207 public static ScopedPrice of(final ScopedPrice template) { 208 ScopedPriceImpl instance = new ScopedPriceImpl(); 209 instance.setId(template.getId()); 210 instance.setValue(template.getValue()); 211 instance.setCurrentValue(template.getCurrentValue()); 212 instance.setCountry(template.getCountry()); 213 instance.setCustomerGroup(template.getCustomerGroup()); 214 instance.setChannel(template.getChannel()); 215 instance.setValidFrom(template.getValidFrom()); 216 instance.setValidUntil(template.getValidUntil()); 217 instance.setDiscounted(template.getDiscounted()); 218 instance.setCustom(template.getCustom()); 219 return instance; 220 } 221 222 /** 223 * factory method to create a deep copy of ScopedPrice 224 * @param template instance to be copied 225 * @return copy instance 226 */ 227 @Nullable 228 public static ScopedPrice deepCopy(@Nullable final ScopedPrice template) { 229 if (template == null) { 230 return null; 231 } 232 ScopedPriceImpl instance = new ScopedPriceImpl(); 233 instance.setId(template.getId()); 234 instance.setValue(com.commercetools.api.models.common.TypedMoney.deepCopy(template.getValue())); 235 instance.setCurrentValue(com.commercetools.api.models.common.TypedMoney.deepCopy(template.getCurrentValue())); 236 instance.setCountry(template.getCountry()); 237 instance.setCustomerGroup( 238 com.commercetools.api.models.customer_group.CustomerGroupReference.deepCopy(template.getCustomerGroup())); 239 instance.setChannel(com.commercetools.api.models.channel.ChannelReference.deepCopy(template.getChannel())); 240 instance.setValidFrom(template.getValidFrom()); 241 instance.setValidUntil(template.getValidUntil()); 242 instance.setDiscounted(com.commercetools.api.models.common.DiscountedPrice.deepCopy(template.getDiscounted())); 243 instance.setCustom(com.commercetools.api.models.type.CustomFields.deepCopy(template.getCustom())); 244 return instance; 245 } 246 247 /** 248 * builder factory method for ScopedPrice 249 * @return builder 250 */ 251 public static ScopedPriceBuilder builder() { 252 return ScopedPriceBuilder.of(); 253 } 254 255 /** 256 * create builder for ScopedPrice instance 257 * @param template instance with prefilled values for the builder 258 * @return builder 259 */ 260 public static ScopedPriceBuilder builder(final ScopedPrice template) { 261 return ScopedPriceBuilder.of(template); 262 } 263 264 /** 265 * accessor map function 266 * @param <T> mapped type 267 * @param helper function to map the object 268 * @return mapped value 269 */ 270 default <T> T withScopedPrice(Function<ScopedPrice, T> helper) { 271 return helper.apply(this); 272 } 273 274 /** 275 * gives a TypeReference for usage with Jackson DataBind 276 * @return TypeReference 277 */ 278 public static com.fasterxml.jackson.core.type.TypeReference<ScopedPrice> typeReference() { 279 return new com.fasterxml.jackson.core.type.TypeReference<ScopedPrice>() { 280 @Override 281 public String toString() { 282 return "TypeReference<ScopedPrice>"; 283 } 284 }; 285 } 286}