001 002package com.commercetools.history.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 * .currencyCode("{currencyCode}") 017 * .centAmount(1) 018 * .fractionDigits(1) 019 * .type(MoneyType.CENT_PRECISION) 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class MoneyBuilder implements Builder<Money> { 026 027 private String currencyCode; 028 029 private Integer centAmount; 030 031 private Integer fractionDigits; 032 033 private com.commercetools.history.models.common.MoneyType type; 034 035 /** 036 * <p>Currency code compliant to ISO 4217.</p> 037 * @param currencyCode value to be set 038 * @return Builder 039 */ 040 041 public MoneyBuilder currencyCode(final String currencyCode) { 042 this.currencyCode = currencyCode; 043 return this; 044 } 045 046 /** 047 * set the value to the centAmount 048 * @param centAmount value to be set 049 * @return Builder 050 */ 051 052 public MoneyBuilder centAmount(final Integer centAmount) { 053 this.centAmount = centAmount; 054 return this; 055 } 056 057 /** 058 * set the value to the fractionDigits 059 * @param fractionDigits value to be set 060 * @return Builder 061 */ 062 063 public MoneyBuilder fractionDigits(final Integer fractionDigits) { 064 this.fractionDigits = fractionDigits; 065 return this; 066 } 067 068 /** 069 * set the value to the type 070 * @param type value to be set 071 * @return Builder 072 */ 073 074 public MoneyBuilder type(final com.commercetools.history.models.common.MoneyType type) { 075 this.type = type; 076 return this; 077 } 078 079 /** 080 * <p>Currency code compliant to ISO 4217.</p> 081 * @return currencyCode 082 */ 083 084 public String getCurrencyCode() { 085 return this.currencyCode; 086 } 087 088 /** 089 * value of centAmount} 090 * @return centAmount 091 */ 092 093 public Integer getCentAmount() { 094 return this.centAmount; 095 } 096 097 /** 098 * value of fractionDigits} 099 * @return fractionDigits 100 */ 101 102 public Integer getFractionDigits() { 103 return this.fractionDigits; 104 } 105 106 /** 107 * value of type} 108 * @return type 109 */ 110 111 public com.commercetools.history.models.common.MoneyType getType() { 112 return this.type; 113 } 114 115 /** 116 * builds Money with checking for non-null required values 117 * @return Money 118 */ 119 public Money build() { 120 Objects.requireNonNull(currencyCode, Money.class + ": currencyCode is missing"); 121 Objects.requireNonNull(centAmount, Money.class + ": centAmount is missing"); 122 Objects.requireNonNull(fractionDigits, Money.class + ": fractionDigits is missing"); 123 Objects.requireNonNull(type, Money.class + ": type is missing"); 124 return new MoneyImpl(currencyCode, centAmount, fractionDigits, type); 125 } 126 127 /** 128 * builds Money without checking for non-null required values 129 * @return Money 130 */ 131 public Money buildUnchecked() { 132 return new MoneyImpl(currencyCode, centAmount, fractionDigits, type); 133 } 134 135 /** 136 * factory method for an instance of MoneyBuilder 137 * @return builder 138 */ 139 public static MoneyBuilder of() { 140 return new MoneyBuilder(); 141 } 142 143 /** 144 * create builder for Money instance 145 * @param template instance with prefilled values for the builder 146 * @return builder 147 */ 148 public static MoneyBuilder of(final Money template) { 149 MoneyBuilder builder = new MoneyBuilder(); 150 builder.currencyCode = template.getCurrencyCode(); 151 builder.centAmount = template.getCentAmount(); 152 builder.fractionDigits = template.getFractionDigits(); 153 builder.type = template.getType(); 154 return builder; 155 } 156 157}