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