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