001 002package com.commercetools.importapi.models.prices; 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 * TaxRate 020 * 021 * <hr> 022 * Example to create an instance using the builder pattern 023 * <div class=code-example> 024 * <pre><code class='java'> 025 * TaxRate taxRate = TaxRate.builder() 026 * .name("{name}") 027 * .amount(0.3) 028 * .includedInPrice(true) 029 * .country("{country}") 030 * .build() 031 * </code></pre> 032 * </div> 033 */ 034@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 035@JsonDeserialize(as = TaxRateImpl.class) 036public interface TaxRate { 037 038 /** 039 * 040 * @return id 041 */ 042 043 @JsonProperty("id") 044 public String getId(); 045 046 /** 047 * 048 * @return name 049 */ 050 @NotNull 051 @JsonProperty("name") 052 public String getName(); 053 054 /** 055 * 056 * @return amount 057 */ 058 @NotNull 059 @JsonProperty("amount") 060 public Double getAmount(); 061 062 /** 063 * 064 * @return includedInPrice 065 */ 066 @NotNull 067 @JsonProperty("includedInPrice") 068 public Boolean getIncludedInPrice(); 069 070 /** 071 * <p>A two-digit country code as per ISO 3166-1 alpha-2.</p> 072 * @return country 073 */ 074 @NotNull 075 @JsonProperty("country") 076 public String getCountry(); 077 078 /** 079 * 080 * @return state 081 */ 082 083 @JsonProperty("state") 084 public String getState(); 085 086 /** 087 * 088 * @return subRates 089 */ 090 @Valid 091 @JsonProperty("subRates") 092 public List<SubRate> getSubRates(); 093 094 /** 095 * set id 096 * @param id value to be set 097 */ 098 099 public void setId(final String id); 100 101 /** 102 * set name 103 * @param name value to be set 104 */ 105 106 public void setName(final String name); 107 108 /** 109 * set amount 110 * @param amount value to be set 111 */ 112 113 public void setAmount(final Double amount); 114 115 /** 116 * set includedInPrice 117 * @param includedInPrice value to be set 118 */ 119 120 public void setIncludedInPrice(final Boolean includedInPrice); 121 122 /** 123 * <p>A two-digit country code as per ISO 3166-1 alpha-2.</p> 124 * @param country value to be set 125 */ 126 127 public void setCountry(final String country); 128 129 /** 130 * set state 131 * @param state value to be set 132 */ 133 134 public void setState(final String state); 135 136 /** 137 * set subRates 138 * @param subRates values to be set 139 */ 140 141 @JsonIgnore 142 public void setSubRates(final SubRate... subRates); 143 144 /** 145 * set subRates 146 * @param subRates values to be set 147 */ 148 149 public void setSubRates(final List<SubRate> subRates); 150 151 /** 152 * factory method 153 * @return instance of TaxRate 154 */ 155 public static TaxRate of() { 156 return new TaxRateImpl(); 157 } 158 159 /** 160 * factory method to create a shallow copy TaxRate 161 * @param template instance to be copied 162 * @return copy instance 163 */ 164 public static TaxRate of(final TaxRate template) { 165 TaxRateImpl instance = new TaxRateImpl(); 166 instance.setId(template.getId()); 167 instance.setName(template.getName()); 168 instance.setAmount(template.getAmount()); 169 instance.setIncludedInPrice(template.getIncludedInPrice()); 170 instance.setCountry(template.getCountry()); 171 instance.setState(template.getState()); 172 instance.setSubRates(template.getSubRates()); 173 return instance; 174 } 175 176 /** 177 * factory method to create a deep copy of TaxRate 178 * @param template instance to be copied 179 * @return copy instance 180 */ 181 @Nullable 182 public static TaxRate deepCopy(@Nullable final TaxRate template) { 183 if (template == null) { 184 return null; 185 } 186 TaxRateImpl instance = new TaxRateImpl(); 187 instance.setId(template.getId()); 188 instance.setName(template.getName()); 189 instance.setAmount(template.getAmount()); 190 instance.setIncludedInPrice(template.getIncludedInPrice()); 191 instance.setCountry(template.getCountry()); 192 instance.setState(template.getState()); 193 instance.setSubRates(Optional.ofNullable(template.getSubRates()) 194 .map(t -> t.stream() 195 .map(com.commercetools.importapi.models.prices.SubRate::deepCopy) 196 .collect(Collectors.toList())) 197 .orElse(null)); 198 return instance; 199 } 200 201 /** 202 * builder factory method for TaxRate 203 * @return builder 204 */ 205 public static TaxRateBuilder builder() { 206 return TaxRateBuilder.of(); 207 } 208 209 /** 210 * create builder for TaxRate instance 211 * @param template instance with prefilled values for the builder 212 * @return builder 213 */ 214 public static TaxRateBuilder builder(final TaxRate template) { 215 return TaxRateBuilder.of(template); 216 } 217 218 /** 219 * accessor map function 220 * @param <T> mapped type 221 * @param helper function to map the object 222 * @return mapped value 223 */ 224 default <T> T withTaxRate(Function<TaxRate, T> helper) { 225 return helper.apply(this); 226 } 227 228 /** 229 * gives a TypeReference for usage with Jackson DataBind 230 * @return TypeReference 231 */ 232 public static com.fasterxml.jackson.core.type.TypeReference<TaxRate> typeReference() { 233 return new com.fasterxml.jackson.core.type.TypeReference<TaxRate>() { 234 @Override 235 public String toString() { 236 return "TypeReference<TaxRate>"; 237 } 238 }; 239 } 240}