001 002package com.commercetools.ml.models.common; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007 008import javax.validation.constraints.NotNull; 009 010import com.fasterxml.jackson.annotation.*; 011import com.fasterxml.jackson.databind.annotation.*; 012 013import io.vrap.rmf.base.client.utils.Generated; 014 015/** 016 * Money 017 * 018 * <hr> 019 * Example to create an instance using the builder pattern 020 * <div class=code-example> 021 * <pre><code class='java'> 022 * Money money = Money.builder() 023 * .centAmount(0.3) 024 * .currencyCode("{currencyCode}") 025 * .build() 026 * </code></pre> 027 * </div> 028 */ 029@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 030@JsonDeserialize(as = MoneyImpl.class) 031public interface Money { 032 033 /** 034 * 035 */ 036 @NotNull 037 @JsonProperty("centAmount") 038 public Long getCentAmount(); 039 040 /** 041 * <p>The currency code compliant to ISO 4217.</p> 042 */ 043 @NotNull 044 @JsonProperty("currencyCode") 045 public String getCurrencyCode(); 046 047 public void setCentAmount(final Long centAmount); 048 049 public void setCurrencyCode(final String currencyCode); 050 051 public static Money of() { 052 return new MoneyImpl(); 053 } 054 055 public static Money of(final Money template) { 056 MoneyImpl instance = new MoneyImpl(); 057 instance.setCentAmount(template.getCentAmount()); 058 instance.setCurrencyCode(template.getCurrencyCode()); 059 return instance; 060 } 061 062 public static MoneyBuilder builder() { 063 return MoneyBuilder.of(); 064 } 065 066 public static MoneyBuilder builder(final Money template) { 067 return MoneyBuilder.of(template); 068 } 069 070 default <T> T withMoney(Function<Money, T> helper) { 071 return helper.apply(this); 072 } 073 074 public static com.fasterxml.jackson.core.type.TypeReference<Money> typeReference() { 075 return new com.fasterxml.jackson.core.type.TypeReference<Money>() { 076 @Override 077 public String toString() { 078 return "TypeReference<Money>"; 079 } 080 }; 081 } 082}