001 002package com.commercetools.history.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 * DiscountedLineItemPortion 019 * 020 * <hr> 021 * Example to create an instance using the builder pattern 022 * <div class=code-example> 023 * <pre><code class='java'> 024 * DiscountedLineItemPortion discountedLineItemPortion = DiscountedLineItemPortion.builder() 025 * .discount(discountBuilder -> discountBuilder) 026 * .discountedAmount(discountedAmountBuilder -> discountedAmountBuilder) 027 * .build() 028 * </code></pre> 029 * </div> 030 */ 031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 032@JsonDeserialize(as = DiscountedLineItemPortionImpl.class) 033public interface DiscountedLineItemPortion { 034 035 /** 036 * 037 * @return discount 038 */ 039 @NotNull 040 @Valid 041 @JsonProperty("discount") 042 public Reference getDiscount(); 043 044 /** 045 * 046 * @return discountedAmount 047 */ 048 @NotNull 049 @Valid 050 @JsonProperty("discountedAmount") 051 public Money getDiscountedAmount(); 052 053 /** 054 * set discount 055 * @param discount value to be set 056 */ 057 058 public void setDiscount(final Reference discount); 059 060 /** 061 * set discountedAmount 062 * @param discountedAmount value to be set 063 */ 064 065 public void setDiscountedAmount(final Money discountedAmount); 066 067 /** 068 * factory method 069 * @return instance of DiscountedLineItemPortion 070 */ 071 public static DiscountedLineItemPortion of() { 072 return new DiscountedLineItemPortionImpl(); 073 } 074 075 /** 076 * factory method to create a shallow copy DiscountedLineItemPortion 077 * @param template instance to be copied 078 * @return copy instance 079 */ 080 public static DiscountedLineItemPortion of(final DiscountedLineItemPortion template) { 081 DiscountedLineItemPortionImpl instance = new DiscountedLineItemPortionImpl(); 082 instance.setDiscount(template.getDiscount()); 083 instance.setDiscountedAmount(template.getDiscountedAmount()); 084 return instance; 085 } 086 087 /** 088 * factory method to create a deep copy of DiscountedLineItemPortion 089 * @param template instance to be copied 090 * @return copy instance 091 */ 092 @Nullable 093 public static DiscountedLineItemPortion deepCopy(@Nullable final DiscountedLineItemPortion template) { 094 if (template == null) { 095 return null; 096 } 097 DiscountedLineItemPortionImpl instance = new DiscountedLineItemPortionImpl(); 098 instance.setDiscount(com.commercetools.history.models.common.Reference.deepCopy(template.getDiscount())); 099 instance.setDiscountedAmount( 100 com.commercetools.history.models.common.Money.deepCopy(template.getDiscountedAmount())); 101 return instance; 102 } 103 104 /** 105 * builder factory method for DiscountedLineItemPortion 106 * @return builder 107 */ 108 public static DiscountedLineItemPortionBuilder builder() { 109 return DiscountedLineItemPortionBuilder.of(); 110 } 111 112 /** 113 * create builder for DiscountedLineItemPortion instance 114 * @param template instance with prefilled values for the builder 115 * @return builder 116 */ 117 public static DiscountedLineItemPortionBuilder builder(final DiscountedLineItemPortion template) { 118 return DiscountedLineItemPortionBuilder.of(template); 119 } 120 121 /** 122 * accessor map function 123 * @param <T> mapped type 124 * @param helper function to map the object 125 * @return mapped value 126 */ 127 default <T> T withDiscountedLineItemPortion(Function<DiscountedLineItemPortion, T> helper) { 128 return helper.apply(this); 129 } 130 131 /** 132 * gives a TypeReference for usage with Jackson DataBind 133 * @return TypeReference 134 */ 135 public static com.fasterxml.jackson.core.type.TypeReference<DiscountedLineItemPortion> typeReference() { 136 return new com.fasterxml.jackson.core.type.TypeReference<DiscountedLineItemPortion>() { 137 @Override 138 public String toString() { 139 return "TypeReference<DiscountedLineItemPortion>"; 140 } 141 }; 142 } 143}