001 002package com.commercetools.api.models.cart_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.commercetools.api.models.common.CentPrecisionMoney; 014import com.fasterxml.jackson.annotation.*; 015import com.fasterxml.jackson.databind.annotation.*; 016 017import io.vrap.rmf.base.client.utils.Generated; 018 019/** 020 * <p>Sets the DiscountedLineItemPrice of the CartDiscountLineItemsTarget or CartDiscountCustomLineItemsTarget to the value specified in the <code>money</code> field, if it is lower than the current Line Item price for the same currency. If the Line Item price is already discounted to a price equal to or lower than the respective price in the <code>money</code> field, this Discount is not applied. If the <code>quantity</code> of the Line Item eligible for the Discount is greater than <code>1</code>, the fixed price discount is only applied to the Line Item portion for which the <code>money</code> value is lesser than their current price.</p> 021 * 022 * <hr> 023 * Example to create an instance using the builder pattern 024 * <div class=code-example> 025 * <pre><code class='java'> 026 * CartDiscountValueFixed cartDiscountValueFixed = CartDiscountValueFixed.builder() 027 * .plusMoney(moneyBuilder -> moneyBuilder) 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 = CartDiscountValueFixedImpl.class) 034public interface CartDiscountValueFixed extends CartDiscountValue, CartDiscountValueFixedMixin { 035 036 /** 037 * discriminator value for CartDiscountValueFixed 038 */ 039 String FIXED = "fixed"; 040 041 /** 042 * <p>Cent precision money values in different currencies.</p> 043 * @return money 044 */ 045 @NotNull 046 @Valid 047 @JsonProperty("money") 048 public List<CentPrecisionMoney> getMoney(); 049 050 /** 051 * <p>Cent precision money values in different currencies.</p> 052 * @param money values to be set 053 */ 054 055 @JsonIgnore 056 public void setMoney(final CentPrecisionMoney... money); 057 058 /** 059 * <p>Cent precision money values in different currencies.</p> 060 * @param money values to be set 061 */ 062 063 public void setMoney(final List<CentPrecisionMoney> money); 064 065 /** 066 * factory method 067 * @return instance of CartDiscountValueFixed 068 */ 069 public static CartDiscountValueFixed of() { 070 return new CartDiscountValueFixedImpl(); 071 } 072 073 /** 074 * factory method to create a shallow copy CartDiscountValueFixed 075 * @param template instance to be copied 076 * @return copy instance 077 */ 078 public static CartDiscountValueFixed of(final CartDiscountValueFixed template) { 079 CartDiscountValueFixedImpl instance = new CartDiscountValueFixedImpl(); 080 instance.setMoney(template.getMoney()); 081 return instance; 082 } 083 084 /** 085 * factory method to create a deep copy of CartDiscountValueFixed 086 * @param template instance to be copied 087 * @return copy instance 088 */ 089 @Nullable 090 public static CartDiscountValueFixed deepCopy(@Nullable final CartDiscountValueFixed template) { 091 if (template == null) { 092 return null; 093 } 094 CartDiscountValueFixedImpl instance = new CartDiscountValueFixedImpl(); 095 instance.setMoney(Optional.ofNullable(template.getMoney()) 096 .map(t -> t.stream() 097 .map(com.commercetools.api.models.common.CentPrecisionMoney::deepCopy) 098 .collect(Collectors.toList())) 099 .orElse(null)); 100 return instance; 101 } 102 103 /** 104 * builder factory method for CartDiscountValueFixed 105 * @return builder 106 */ 107 public static CartDiscountValueFixedBuilder builder() { 108 return CartDiscountValueFixedBuilder.of(); 109 } 110 111 /** 112 * create builder for CartDiscountValueFixed instance 113 * @param template instance with prefilled values for the builder 114 * @return builder 115 */ 116 public static CartDiscountValueFixedBuilder builder(final CartDiscountValueFixed template) { 117 return CartDiscountValueFixedBuilder.of(template); 118 } 119 120 /** 121 * accessor map function 122 * @param <T> mapped type 123 * @param helper function to map the object 124 * @return mapped value 125 */ 126 default <T> T withCartDiscountValueFixed(Function<CartDiscountValueFixed, T> helper) { 127 return helper.apply(this); 128 } 129 130 /** 131 * gives a TypeReference for usage with Jackson DataBind 132 * @return TypeReference 133 */ 134 public static com.fasterxml.jackson.core.type.TypeReference<CartDiscountValueFixed> typeReference() { 135 return new com.fasterxml.jackson.core.type.TypeReference<CartDiscountValueFixed>() { 136 @Override 137 public String toString() { 138 return "TypeReference<CartDiscountValueFixed>"; 139 } 140 }; 141 } 142}