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 * 031 */ 032 033 public MoneyBuilder centAmount(final Long centAmount) { 034 this.centAmount = centAmount; 035 return this; 036 } 037 038 /** 039 * <p>The currency code compliant to ISO 4217.</p> 040 */ 041 042 public MoneyBuilder currencyCode(final String currencyCode) { 043 this.currencyCode = currencyCode; 044 return this; 045 } 046 047 public Long getCentAmount() { 048 return this.centAmount; 049 } 050 051 public String getCurrencyCode() { 052 return this.currencyCode; 053 } 054 055 public Money build() { 056 Objects.requireNonNull(centAmount, Money.class + ": centAmount is missing"); 057 Objects.requireNonNull(currencyCode, Money.class + ": currencyCode is missing"); 058 return new MoneyImpl(centAmount, currencyCode); 059 } 060 061 /** 062 * builds Money without checking for non null required values 063 */ 064 public Money buildUnchecked() { 065 return new MoneyImpl(centAmount, currencyCode); 066 } 067 068 public static MoneyBuilder of() { 069 return new MoneyBuilder(); 070 } 071 072 public static MoneyBuilder of(final Money template) { 073 MoneyBuilder builder = new MoneyBuilder(); 074 builder.centAmount = template.getCentAmount(); 075 builder.currencyCode = template.getCurrencyCode(); 076 return builder; 077 } 078 079}