001
002package com.commercetools.history.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 * DiscountCodeInfoBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     DiscountCodeInfo discountCodeInfo = DiscountCodeInfo.builder()
017 *             .discountCode(discountCodeBuilder -> discountCodeBuilder)
018 *             .state(DiscountCodeState.NOT_ACTIVE)
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 DiscountCodeInfoBuilder implements Builder<DiscountCodeInfo> {
025
026    private com.commercetools.history.models.common.Reference discountCode;
027
028    private com.commercetools.history.models.common.DiscountCodeState state;
029
030    /**
031     * set the value to the discountCode using the builder function
032     * @param builder function to build the discountCode value
033     * @return Builder
034     */
035
036    public DiscountCodeInfoBuilder discountCode(
037            Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.ReferenceBuilder> builder) {
038        this.discountCode = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of()).build();
039        return this;
040    }
041
042    /**
043     * set the value to the discountCode using the builder function
044     * @param builder function to build the discountCode value
045     * @return Builder
046     */
047
048    public DiscountCodeInfoBuilder withDiscountCode(
049            Function<com.commercetools.history.models.common.ReferenceBuilder, com.commercetools.history.models.common.Reference> builder) {
050        this.discountCode = builder.apply(com.commercetools.history.models.common.ReferenceBuilder.of());
051        return this;
052    }
053
054    /**
055     * set the value to the discountCode
056     * @param discountCode value to be set
057     * @return Builder
058     */
059
060    public DiscountCodeInfoBuilder discountCode(final com.commercetools.history.models.common.Reference discountCode) {
061        this.discountCode = discountCode;
062        return this;
063    }
064
065    /**
066     * set the value to the state
067     * @param state value to be set
068     * @return Builder
069     */
070
071    public DiscountCodeInfoBuilder state(final com.commercetools.history.models.common.DiscountCodeState state) {
072        this.state = state;
073        return this;
074    }
075
076    /**
077     * value of discountCode}
078     * @return discountCode
079     */
080
081    public com.commercetools.history.models.common.Reference getDiscountCode() {
082        return this.discountCode;
083    }
084
085    /**
086     * value of state}
087     * @return state
088     */
089
090    public com.commercetools.history.models.common.DiscountCodeState getState() {
091        return this.state;
092    }
093
094    /**
095     * builds DiscountCodeInfo with checking for non-null required values
096     * @return DiscountCodeInfo
097     */
098    public DiscountCodeInfo build() {
099        Objects.requireNonNull(discountCode, DiscountCodeInfo.class + ": discountCode is missing");
100        Objects.requireNonNull(state, DiscountCodeInfo.class + ": state is missing");
101        return new DiscountCodeInfoImpl(discountCode, state);
102    }
103
104    /**
105     * builds DiscountCodeInfo without checking for non-null required values
106     * @return DiscountCodeInfo
107     */
108    public DiscountCodeInfo buildUnchecked() {
109        return new DiscountCodeInfoImpl(discountCode, state);
110    }
111
112    /**
113     * factory method for an instance of DiscountCodeInfoBuilder
114     * @return builder
115     */
116    public static DiscountCodeInfoBuilder of() {
117        return new DiscountCodeInfoBuilder();
118    }
119
120    /**
121     * create builder for DiscountCodeInfo instance
122     * @param template instance with prefilled values for the builder
123     * @return builder
124     */
125    public static DiscountCodeInfoBuilder of(final DiscountCodeInfo template) {
126        DiscountCodeInfoBuilder builder = new DiscountCodeInfoBuilder();
127        builder.discountCode = template.getDiscountCode();
128        builder.state = template.getState();
129        return builder;
130    }
131
132}