001
002package com.commercetools.api.models.common;
003
004import java.util.*;
005import java.util.function.Function;
006
007import io.vrap.rmf.base.client.Builder;
008import io.vrap.rmf.base.client.utils.Generated;
009
010/**
011 * DiscountedPriceBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     DiscountedPrice discountedPrice = DiscountedPrice.builder()
017 *             .value(valueBuilder -> valueBuilder)
018 *             .discount(discountBuilder -> discountBuilder)
019 *             .build()
020 * </code></pre>
021 * </div>
022 */
023@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
024public class DiscountedPriceBuilder implements Builder<DiscountedPrice> {
025
026    private com.commercetools.api.models.common.TypedMoney value;
027
028    private com.commercetools.api.models.product_discount.ProductDiscountReference discount;
029
030    /**
031     *  <p>Money value of the discounted price.</p>
032     * @param value value to be set
033     * @return Builder
034     */
035
036    public DiscountedPriceBuilder value(final com.commercetools.api.models.common.TypedMoney value) {
037        this.value = value;
038        return this;
039    }
040
041    /**
042     *  <p>Money value of the discounted price.</p>
043     * @param builder function to build the value value
044     * @return Builder
045     */
046
047    public DiscountedPriceBuilder value(
048            Function<com.commercetools.api.models.common.TypedMoneyBuilder, Builder<? extends com.commercetools.api.models.common.TypedMoney>> builder) {
049        this.value = builder.apply(com.commercetools.api.models.common.TypedMoneyBuilder.of()).build();
050        return this;
051    }
052
053    /**
054     *  <p>ProductDiscount related to the discounted price.</p>
055     * @param builder function to build the discount value
056     * @return Builder
057     */
058
059    public DiscountedPriceBuilder discount(
060            Function<com.commercetools.api.models.product_discount.ProductDiscountReferenceBuilder, com.commercetools.api.models.product_discount.ProductDiscountReferenceBuilder> builder) {
061        this.discount = builder
062                .apply(com.commercetools.api.models.product_discount.ProductDiscountReferenceBuilder.of())
063                .build();
064        return this;
065    }
066
067    /**
068     *  <p>ProductDiscount related to the discounted price.</p>
069     * @param builder function to build the discount value
070     * @return Builder
071     */
072
073    public DiscountedPriceBuilder withDiscount(
074            Function<com.commercetools.api.models.product_discount.ProductDiscountReferenceBuilder, com.commercetools.api.models.product_discount.ProductDiscountReference> builder) {
075        this.discount = builder
076                .apply(com.commercetools.api.models.product_discount.ProductDiscountReferenceBuilder.of());
077        return this;
078    }
079
080    /**
081     *  <p>ProductDiscount related to the discounted price.</p>
082     * @param discount value to be set
083     * @return Builder
084     */
085
086    public DiscountedPriceBuilder discount(
087            final com.commercetools.api.models.product_discount.ProductDiscountReference discount) {
088        this.discount = discount;
089        return this;
090    }
091
092    /**
093     *  <p>Money value of the discounted price.</p>
094     * @return value
095     */
096
097    public com.commercetools.api.models.common.TypedMoney getValue() {
098        return this.value;
099    }
100
101    /**
102     *  <p>ProductDiscount related to the discounted price.</p>
103     * @return discount
104     */
105
106    public com.commercetools.api.models.product_discount.ProductDiscountReference getDiscount() {
107        return this.discount;
108    }
109
110    /**
111     * builds DiscountedPrice with checking for non-null required values
112     * @return DiscountedPrice
113     */
114    public DiscountedPrice build() {
115        Objects.requireNonNull(value, DiscountedPrice.class + ": value is missing");
116        Objects.requireNonNull(discount, DiscountedPrice.class + ": discount is missing");
117        return new DiscountedPriceImpl(value, discount);
118    }
119
120    /**
121     * builds DiscountedPrice without checking for non-null required values
122     * @return DiscountedPrice
123     */
124    public DiscountedPrice buildUnchecked() {
125        return new DiscountedPriceImpl(value, discount);
126    }
127
128    /**
129     * factory method for an instance of DiscountedPriceBuilder
130     * @return builder
131     */
132    public static DiscountedPriceBuilder of() {
133        return new DiscountedPriceBuilder();
134    }
135
136    /**
137     * create builder for DiscountedPrice instance
138     * @param template instance with prefilled values for the builder
139     * @return builder
140     */
141    public static DiscountedPriceBuilder of(final DiscountedPrice template) {
142        DiscountedPriceBuilder builder = new DiscountedPriceBuilder();
143        builder.value = template.getValue();
144        builder.discount = template.getDiscount();
145        return builder;
146    }
147
148}