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