001 002package com.commercetools.api.models.tax_category; 003 004import java.time.*; 005import java.util.*; 006import java.util.function.Function; 007import java.util.stream.Collectors; 008 009import javax.annotation.Nullable; 010import javax.validation.Valid; 011import javax.validation.constraints.NotNull; 012 013import com.fasterxml.jackson.annotation.*; 014import com.fasterxml.jackson.databind.annotation.*; 015 016import io.vrap.rmf.base.client.utils.Generated; 017 018/** 019 * TaxRateDraft 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * TaxRateDraft taxRateDraft = TaxRateDraft.builder() 026 * .name("{name}") 027 * .includedInPrice(true) 028 * .country("{country}") 029 * .build() 030 * </code></pre> 031 * </div> 032 */ 033@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 034@JsonDeserialize(as = TaxRateDraftImpl.class) 035public interface TaxRateDraft extends io.vrap.rmf.base.client.Draft<TaxRateDraft> { 036 037 /** 038 * <p>Name of the TaxRate.</p> 039 * @return name 040 */ 041 @NotNull 042 @JsonProperty("name") 043 public String getName(); 044 045 /** 046 * <p>Tax rate. Must be supplied if no <code>subRates</code> are specified. If <code>subRates</code> are specified, this field can be omitted or it must be the sum of amounts of all <code>subRates</code>.</p> 047 * @return amount 048 */ 049 050 @JsonProperty("amount") 051 public Double getAmount(); 052 053 /** 054 * <p>If <code>true</code>, tax is included in Embedded Prices or Standalone Prices, and the <code>taxedPrice</code> is present on LineItems. In this case, the <code>totalNet</code> price on TaxedPrice includes the TaxRate.</p> 055 * @return includedInPrice 056 */ 057 @NotNull 058 @JsonProperty("includedInPrice") 059 public Boolean getIncludedInPrice(); 060 061 /** 062 * <p>Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.</p> 063 * @return country 064 */ 065 @NotNull 066 @JsonProperty("country") 067 public String getCountry(); 068 069 /** 070 * <p>State within the country, such as Texas in the United States.</p> 071 * @return state 072 */ 073 074 @JsonProperty("state") 075 public String getState(); 076 077 /** 078 * <p>Used to calculate the taxPortions field in a Cart or Order. It is useful if the total tax of a country (such as the US) is a combination of multiple taxes (such as state and local taxes).</p> 079 * @return subRates 080 */ 081 @Valid 082 @JsonProperty("subRates") 083 public List<SubRate> getSubRates(); 084 085 /** 086 * <p>User-defined unique identifier of the TaxRate.</p> 087 * @return key 088 */ 089 090 @JsonProperty("key") 091 public String getKey(); 092 093 /** 094 * <p>Name of the TaxRate.</p> 095 * @param name value to be set 096 */ 097 098 public void setName(final String name); 099 100 /** 101 * <p>Tax rate. Must be supplied if no <code>subRates</code> are specified. If <code>subRates</code> are specified, this field can be omitted or it must be the sum of amounts of all <code>subRates</code>.</p> 102 * @param amount value to be set 103 */ 104 105 public void setAmount(final Double amount); 106 107 /** 108 * <p>If <code>true</code>, tax is included in Embedded Prices or Standalone Prices, and the <code>taxedPrice</code> is present on LineItems. In this case, the <code>totalNet</code> price on TaxedPrice includes the TaxRate.</p> 109 * @param includedInPrice value to be set 110 */ 111 112 public void setIncludedInPrice(final Boolean includedInPrice); 113 114 /** 115 * <p>Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.</p> 116 * @param country value to be set 117 */ 118 119 public void setCountry(final String country); 120 121 /** 122 * <p>State within the country, such as Texas in the United States.</p> 123 * @param state value to be set 124 */ 125 126 public void setState(final String state); 127 128 /** 129 * <p>Used to calculate the taxPortions field in a Cart or Order. It is useful if the total tax of a country (such as the US) is a combination of multiple taxes (such as state and local taxes).</p> 130 * @param subRates values to be set 131 */ 132 133 @JsonIgnore 134 public void setSubRates(final SubRate... subRates); 135 136 /** 137 * <p>Used to calculate the taxPortions field in a Cart or Order. It is useful if the total tax of a country (such as the US) is a combination of multiple taxes (such as state and local taxes).</p> 138 * @param subRates values to be set 139 */ 140 141 public void setSubRates(final List<SubRate> subRates); 142 143 /** 144 * <p>User-defined unique identifier of the TaxRate.</p> 145 * @param key value to be set 146 */ 147 148 public void setKey(final String key); 149 150 /** 151 * factory method 152 * @return instance of TaxRateDraft 153 */ 154 public static TaxRateDraft of() { 155 return new TaxRateDraftImpl(); 156 } 157 158 /** 159 * factory method to create a shallow copy TaxRateDraft 160 * @param template instance to be copied 161 * @return copy instance 162 */ 163 public static TaxRateDraft of(final TaxRateDraft template) { 164 TaxRateDraftImpl instance = new TaxRateDraftImpl(); 165 instance.setName(template.getName()); 166 instance.setAmount(template.getAmount()); 167 instance.setIncludedInPrice(template.getIncludedInPrice()); 168 instance.setCountry(template.getCountry()); 169 instance.setState(template.getState()); 170 instance.setSubRates(template.getSubRates()); 171 instance.setKey(template.getKey()); 172 return instance; 173 } 174 175 /** 176 * factory method to create a deep copy of TaxRateDraft 177 * @param template instance to be copied 178 * @return copy instance 179 */ 180 @Nullable 181 public static TaxRateDraft deepCopy(@Nullable final TaxRateDraft template) { 182 if (template == null) { 183 return null; 184 } 185 TaxRateDraftImpl instance = new TaxRateDraftImpl(); 186 instance.setName(template.getName()); 187 instance.setAmount(template.getAmount()); 188 instance.setIncludedInPrice(template.getIncludedInPrice()); 189 instance.setCountry(template.getCountry()); 190 instance.setState(template.getState()); 191 instance.setSubRates(Optional.ofNullable(template.getSubRates()) 192 .map(t -> t.stream() 193 .map(com.commercetools.api.models.tax_category.SubRate::deepCopy) 194 .collect(Collectors.toList())) 195 .orElse(null)); 196 instance.setKey(template.getKey()); 197 return instance; 198 } 199 200 /** 201 * builder factory method for TaxRateDraft 202 * @return builder 203 */ 204 public static TaxRateDraftBuilder builder() { 205 return TaxRateDraftBuilder.of(); 206 } 207 208 /** 209 * create builder for TaxRateDraft instance 210 * @param template instance with prefilled values for the builder 211 * @return builder 212 */ 213 public static TaxRateDraftBuilder builder(final TaxRateDraft template) { 214 return TaxRateDraftBuilder.of(template); 215 } 216 217 /** 218 * accessor map function 219 * @param <T> mapped type 220 * @param helper function to map the object 221 * @return mapped value 222 */ 223 default <T> T withTaxRateDraft(Function<TaxRateDraft, T> helper) { 224 return helper.apply(this); 225 } 226 227 /** 228 * gives a TypeReference for usage with Jackson DataBind 229 * @return TypeReference 230 */ 231 public static com.fasterxml.jackson.core.type.TypeReference<TaxRateDraft> typeReference() { 232 return new com.fasterxml.jackson.core.type.TypeReference<TaxRateDraft>() { 233 @Override 234 public String toString() { 235 return "TypeReference<TaxRateDraft>"; 236 } 237 }; 238 } 239}