001
002package com.commercetools.ml.models.common;
003
004import java.util.*;
005
006import io.vrap.rmf.base.client.Builder;
007import io.vrap.rmf.base.client.utils.Generated;
008
009/**
010 * MoneyBuilder
011 * <hr>
012 * Example to create an instance using the builder pattern
013 * <div class=code-example>
014 * <pre><code class='java'>
015 *     Money money = Money.builder()
016 *             .centAmount(0.3)
017 *             .currencyCode("{currencyCode}")
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 MoneyBuilder implements Builder<Money> {
024
025    private Long centAmount;
026
027    private String currencyCode;
028
029    /**
030     * set the value to the centAmount
031     * @param centAmount value to be set
032     * @return Builder
033     */
034
035    public MoneyBuilder centAmount(final Long centAmount) {
036        this.centAmount = centAmount;
037        return this;
038    }
039
040    /**
041     *  <p>The currency code compliant to ISO 4217.</p>
042     * @param currencyCode value to be set
043     * @return Builder
044     */
045
046    public MoneyBuilder currencyCode(final String currencyCode) {
047        this.currencyCode = currencyCode;
048        return this;
049    }
050
051    /**
052     * value of centAmount}
053     * @return centAmount
054     */
055
056    public Long getCentAmount() {
057        return this.centAmount;
058    }
059
060    /**
061     *  <p>The currency code compliant to ISO 4217.</p>
062     * @return currencyCode
063     */
064
065    public String getCurrencyCode() {
066        return this.currencyCode;
067    }
068
069    /**
070     * builds Money with checking for non-null required values
071     * @return Money
072     */
073    public Money build() {
074        Objects.requireNonNull(centAmount, Money.class + ": centAmount is missing");
075        Objects.requireNonNull(currencyCode, Money.class + ": currencyCode is missing");
076        return new MoneyImpl(centAmount, currencyCode);
077    }
078
079    /**
080     * builds Money without checking for non-null required values
081     * @return Money
082     */
083    public Money buildUnchecked() {
084        return new MoneyImpl(centAmount, currencyCode);
085    }
086
087    /**
088     * factory method for an instance of MoneyBuilder
089     * @return builder
090     */
091    public static MoneyBuilder of() {
092        return new MoneyBuilder();
093    }
094
095    /**
096     * create builder for Money instance
097     * @param template instance with prefilled values for the builder
098     * @return builder
099     */
100    public static MoneyBuilder of(final Money template) {
101        MoneyBuilder builder = new MoneyBuilder();
102        builder.centAmount = template.getCentAmount();
103        builder.currencyCode = template.getCurrencyCode();
104        return builder;
105    }
106
107}