001 002package com.commercetools.history.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.annotation.Nullable; 009import javax.validation.constraints.NotNull; 010 011import com.fasterxml.jackson.annotation.*; 012import com.fasterxml.jackson.databind.annotation.*; 013 014import io.vrap.rmf.base.client.utils.Generated; 015 016/** 017 * Money 018 * 019 * <hr> 020 * Example to create an instance using the builder pattern 021 * <div class=code-example> 022 * <pre><code class='java'> 023 * Money money = Money.builder() 024 * .currencyCode("{currencyCode}") 025 * .centAmount(1) 026 * .fractionDigits(1) 027 * .type(MoneyType.CENT_PRECISION) 028 * .build() 029 * </code></pre> 030 * </div> 031 */ 032@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 033@JsonDeserialize(as = MoneyImpl.class) 034public interface Money { 035 036 /** 037 * <p>Currency code compliant to ISO 4217.</p> 038 * @return currencyCode 039 */ 040 @NotNull 041 @JsonProperty("currencyCode") 042 public String getCurrencyCode(); 043 044 /** 045 * 046 * @return centAmount 047 */ 048 @NotNull 049 @JsonProperty("centAmount") 050 public Integer getCentAmount(); 051 052 /** 053 * 054 * @return fractionDigits 055 */ 056 @NotNull 057 @JsonProperty("fractionDigits") 058 public Integer getFractionDigits(); 059 060 /** 061 * 062 * @return type 063 */ 064 @NotNull 065 @JsonProperty("type") 066 public MoneyType getType(); 067 068 /** 069 * <p>Currency code compliant to ISO 4217.</p> 070 * @param currencyCode value to be set 071 */ 072 073 public void setCurrencyCode(final String currencyCode); 074 075 /** 076 * set centAmount 077 * @param centAmount value to be set 078 */ 079 080 public void setCentAmount(final Integer centAmount); 081 082 /** 083 * set fractionDigits 084 * @param fractionDigits value to be set 085 */ 086 087 public void setFractionDigits(final Integer fractionDigits); 088 089 /** 090 * set type 091 * @param type value to be set 092 */ 093 094 public void setType(final MoneyType type); 095 096 /** 097 * factory method 098 * @return instance of Money 099 */ 100 public static Money of() { 101 return new MoneyImpl(); 102 } 103 104 /** 105 * factory method to create a shallow copy Money 106 * @param template instance to be copied 107 * @return copy instance 108 */ 109 public static Money of(final Money template) { 110 MoneyImpl instance = new MoneyImpl(); 111 instance.setCurrencyCode(template.getCurrencyCode()); 112 instance.setCentAmount(template.getCentAmount()); 113 instance.setFractionDigits(template.getFractionDigits()); 114 instance.setType(template.getType()); 115 return instance; 116 } 117 118 /** 119 * factory method to create a deep copy of Money 120 * @param template instance to be copied 121 * @return copy instance 122 */ 123 @Nullable 124 public static Money deepCopy(@Nullable final Money template) { 125 if (template == null) { 126 return null; 127 } 128 MoneyImpl instance = new MoneyImpl(); 129 instance.setCurrencyCode(template.getCurrencyCode()); 130 instance.setCentAmount(template.getCentAmount()); 131 instance.setFractionDigits(template.getFractionDigits()); 132 instance.setType(template.getType()); 133 return instance; 134 } 135 136 /** 137 * builder factory method for Money 138 * @return builder 139 */ 140 public static MoneyBuilder builder() { 141 return MoneyBuilder.of(); 142 } 143 144 /** 145 * create builder for Money instance 146 * @param template instance with prefilled values for the builder 147 * @return builder 148 */ 149 public static MoneyBuilder builder(final Money template) { 150 return MoneyBuilder.of(template); 151 } 152 153 /** 154 * accessor map function 155 * @param <T> mapped type 156 * @param helper function to map the object 157 * @return mapped value 158 */ 159 default <T> T withMoney(Function<Money, T> helper) { 160 return helper.apply(this); 161 } 162 163 /** 164 * gives a TypeReference for usage with Jackson DataBind 165 * @return TypeReference 166 */ 167 public static com.fasterxml.jackson.core.type.TypeReference<Money> typeReference() { 168 return new com.fasterxml.jackson.core.type.TypeReference<Money>() { 169 @Override 170 public String toString() { 171 return "TypeReference<Money>"; 172 } 173 }; 174 } 175}