001
002package com.commercetools.api.models.message;
003
004import java.util.*;
005import java.util.function.Function;
006
007import javax.annotation.Nullable;
008
009import io.vrap.rmf.base.client.Builder;
010import io.vrap.rmf.base.client.utils.Generated;
011
012/**
013 * OrderDiscountCodeStateSetMessagePayloadBuilder
014 * <hr>
015 * Example to create an instance using the builder pattern
016 * <div class=code-example>
017 * <pre><code class='java'>
018 *     OrderDiscountCodeStateSetMessagePayload orderDiscountCodeStateSetMessagePayload = OrderDiscountCodeStateSetMessagePayload.builder()
019 *             .discountCode(discountCodeBuilder -> discountCodeBuilder)
020 *             .state(DiscountCodeState.NOT_ACTIVE)
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class OrderDiscountCodeStateSetMessagePayloadBuilder
027        implements Builder<OrderDiscountCodeStateSetMessagePayload> {
028
029    private com.commercetools.api.models.discount_code.DiscountCodeReference discountCode;
030
031    private com.commercetools.api.models.cart.DiscountCodeState state;
032
033    @Nullable
034    private com.commercetools.api.models.cart.DiscountCodeState oldState;
035
036    /**
037     *  <p>DiscountCode that changed due to the recalculation.</p>
038     * @param builder function to build the discountCode value
039     * @return Builder
040     */
041
042    public OrderDiscountCodeStateSetMessagePayloadBuilder discountCode(
043            Function<com.commercetools.api.models.discount_code.DiscountCodeReferenceBuilder, com.commercetools.api.models.discount_code.DiscountCodeReferenceBuilder> builder) {
044        this.discountCode = builder.apply(com.commercetools.api.models.discount_code.DiscountCodeReferenceBuilder.of())
045                .build();
046        return this;
047    }
048
049    /**
050     *  <p>DiscountCode that changed due to the recalculation.</p>
051     * @param builder function to build the discountCode value
052     * @return Builder
053     */
054
055    public OrderDiscountCodeStateSetMessagePayloadBuilder withDiscountCode(
056            Function<com.commercetools.api.models.discount_code.DiscountCodeReferenceBuilder, com.commercetools.api.models.discount_code.DiscountCodeReference> builder) {
057        this.discountCode = builder.apply(com.commercetools.api.models.discount_code.DiscountCodeReferenceBuilder.of());
058        return this;
059    }
060
061    /**
062     *  <p>DiscountCode that changed due to the recalculation.</p>
063     * @param discountCode value to be set
064     * @return Builder
065     */
066
067    public OrderDiscountCodeStateSetMessagePayloadBuilder discountCode(
068            final com.commercetools.api.models.discount_code.DiscountCodeReference discountCode) {
069        this.discountCode = discountCode;
070        return this;
071    }
072
073    /**
074     *  <p>DiscountCodeState after the recalculation.</p>
075     * @param state value to be set
076     * @return Builder
077     */
078
079    public OrderDiscountCodeStateSetMessagePayloadBuilder state(
080            final com.commercetools.api.models.cart.DiscountCodeState state) {
081        this.state = state;
082        return this;
083    }
084
085    /**
086     *  <p>DiscountCodeState before the recalculation.</p>
087     * @param oldState value to be set
088     * @return Builder
089     */
090
091    public OrderDiscountCodeStateSetMessagePayloadBuilder oldState(
092            @Nullable final com.commercetools.api.models.cart.DiscountCodeState oldState) {
093        this.oldState = oldState;
094        return this;
095    }
096
097    /**
098     *  <p>DiscountCode that changed due to the recalculation.</p>
099     * @return discountCode
100     */
101
102    public com.commercetools.api.models.discount_code.DiscountCodeReference getDiscountCode() {
103        return this.discountCode;
104    }
105
106    /**
107     *  <p>DiscountCodeState after the recalculation.</p>
108     * @return state
109     */
110
111    public com.commercetools.api.models.cart.DiscountCodeState getState() {
112        return this.state;
113    }
114
115    /**
116     *  <p>DiscountCodeState before the recalculation.</p>
117     * @return oldState
118     */
119
120    @Nullable
121    public com.commercetools.api.models.cart.DiscountCodeState getOldState() {
122        return this.oldState;
123    }
124
125    /**
126     * builds OrderDiscountCodeStateSetMessagePayload with checking for non-null required values
127     * @return OrderDiscountCodeStateSetMessagePayload
128     */
129    public OrderDiscountCodeStateSetMessagePayload build() {
130        Objects.requireNonNull(discountCode,
131            OrderDiscountCodeStateSetMessagePayload.class + ": discountCode is missing");
132        Objects.requireNonNull(state, OrderDiscountCodeStateSetMessagePayload.class + ": state is missing");
133        return new OrderDiscountCodeStateSetMessagePayloadImpl(discountCode, state, oldState);
134    }
135
136    /**
137     * builds OrderDiscountCodeStateSetMessagePayload without checking for non-null required values
138     * @return OrderDiscountCodeStateSetMessagePayload
139     */
140    public OrderDiscountCodeStateSetMessagePayload buildUnchecked() {
141        return new OrderDiscountCodeStateSetMessagePayloadImpl(discountCode, state, oldState);
142    }
143
144    /**
145     * factory method for an instance of OrderDiscountCodeStateSetMessagePayloadBuilder
146     * @return builder
147     */
148    public static OrderDiscountCodeStateSetMessagePayloadBuilder of() {
149        return new OrderDiscountCodeStateSetMessagePayloadBuilder();
150    }
151
152    /**
153     * create builder for OrderDiscountCodeStateSetMessagePayload instance
154     * @param template instance with prefilled values for the builder
155     * @return builder
156     */
157    public static OrderDiscountCodeStateSetMessagePayloadBuilder of(
158            final OrderDiscountCodeStateSetMessagePayload template) {
159        OrderDiscountCodeStateSetMessagePayloadBuilder builder = new OrderDiscountCodeStateSetMessagePayloadBuilder();
160        builder.discountCode = template.getDiscountCode();
161        builder.state = template.getState();
162        builder.oldState = template.getOldState();
163        return builder;
164    }
165
166}