001
002package com.commercetools.api.models.cart_discount;
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 * CartDiscountChangeTargetActionBuilder
012 * <hr>
013 * Example to create an instance using the builder pattern
014 * <div class=code-example>
015 * <pre><code class='java'>
016 *     CartDiscountChangeTargetAction cartDiscountChangeTargetAction = CartDiscountChangeTargetAction.builder()
017 *             .target(targetBuilder -> targetBuilder)
018 *             .build()
019 * </code></pre>
020 * </div>
021 */
022@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
023public class CartDiscountChangeTargetActionBuilder implements Builder<CartDiscountChangeTargetAction> {
024
025    private com.commercetools.api.models.cart_discount.CartDiscountTarget target;
026
027    /**
028     *  <p>New value to set.</p>
029     * @param target value to be set
030     * @return Builder
031     */
032
033    public CartDiscountChangeTargetActionBuilder target(
034            final com.commercetools.api.models.cart_discount.CartDiscountTarget target) {
035        this.target = target;
036        return this;
037    }
038
039    /**
040     *  <p>New value to set.</p>
041     * @param builder function to build the target value
042     * @return Builder
043     */
044
045    public CartDiscountChangeTargetActionBuilder target(
046            Function<com.commercetools.api.models.cart_discount.CartDiscountTargetBuilder, Builder<? extends com.commercetools.api.models.cart_discount.CartDiscountTarget>> builder) {
047        this.target = builder.apply(com.commercetools.api.models.cart_discount.CartDiscountTargetBuilder.of()).build();
048        return this;
049    }
050
051    /**
052     *  <p>New value to set.</p>
053     * @return target
054     */
055
056    public com.commercetools.api.models.cart_discount.CartDiscountTarget getTarget() {
057        return this.target;
058    }
059
060    /**
061     * builds CartDiscountChangeTargetAction with checking for non-null required values
062     * @return CartDiscountChangeTargetAction
063     */
064    public CartDiscountChangeTargetAction build() {
065        Objects.requireNonNull(target, CartDiscountChangeTargetAction.class + ": target is missing");
066        return new CartDiscountChangeTargetActionImpl(target);
067    }
068
069    /**
070     * builds CartDiscountChangeTargetAction without checking for non-null required values
071     * @return CartDiscountChangeTargetAction
072     */
073    public CartDiscountChangeTargetAction buildUnchecked() {
074        return new CartDiscountChangeTargetActionImpl(target);
075    }
076
077    /**
078     * factory method for an instance of CartDiscountChangeTargetActionBuilder
079     * @return builder
080     */
081    public static CartDiscountChangeTargetActionBuilder of() {
082        return new CartDiscountChangeTargetActionBuilder();
083    }
084
085    /**
086     * create builder for CartDiscountChangeTargetAction instance
087     * @param template instance with prefilled values for the builder
088     * @return builder
089     */
090    public static CartDiscountChangeTargetActionBuilder of(final CartDiscountChangeTargetAction template) {
091        CartDiscountChangeTargetActionBuilder builder = new CartDiscountChangeTargetActionBuilder();
092        builder.target = template.getTarget();
093        return builder;
094    }
095
096}