com.commercetools.history.models.common.TaxRate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commercetools-sdk-java-history Show documentation
Show all versions of commercetools-sdk-java-history Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package com.commercetools.history.models.common;
import java.time.*;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.*;
import io.vrap.rmf.base.client.utils.Generated;
/**
* Shape of the value for addTaxRate
and removeTaxRate
actions
*
*
* Example to create an instance using the builder pattern
*
*
* TaxRate taxRate = TaxRate.builder()
* .id("{id}")
* .name("{name}")
* .amount(1)
* .includedInPrice(true)
* .country("{country}")
* .state("{state}")
* .plusSubRates(subRatesBuilder -> subRatesBuilder)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
@JsonDeserialize(as = TaxRateImpl.class)
public interface TaxRate {
/**
* The ID is always set if the tax rate is part of a TaxCategory. The external tax rates in a Cart do not contain an id
.
* @return id
*/
@NotNull
@JsonProperty("id")
public String getId();
/**
*
* @return name
*/
@NotNull
@JsonProperty("name")
public String getName();
/**
* Percentage in the range of [0..1]. The sum of the amounts of all subRates
, if there are any.
* @return amount
*/
@NotNull
@JsonProperty("amount")
public Integer getAmount();
/**
*
* @return includedInPrice
*/
@NotNull
@JsonProperty("includedInPrice")
public Boolean getIncludedInPrice();
/**
* Two-digit country code as per ISO 3166-1 alpha-2.
* @return country
*/
@NotNull
@JsonProperty("country")
public String getCountry();
/**
* The state in the country
* @return state
*/
@NotNull
@JsonProperty("state")
public String getState();
/**
*
* @return subRates
*/
@NotNull
@Valid
@JsonProperty("subRates")
public List getSubRates();
/**
* The ID is always set if the tax rate is part of a TaxCategory. The external tax rates in a Cart do not contain an id
.
* @param id value to be set
*/
public void setId(final String id);
/**
* set name
* @param name value to be set
*/
public void setName(final String name);
/**
* Percentage in the range of [0..1]. The sum of the amounts of all subRates
, if there are any.
* @param amount value to be set
*/
public void setAmount(final Integer amount);
/**
* set includedInPrice
* @param includedInPrice value to be set
*/
public void setIncludedInPrice(final Boolean includedInPrice);
/**
* Two-digit country code as per ISO 3166-1 alpha-2.
* @param country value to be set
*/
public void setCountry(final String country);
/**
* The state in the country
* @param state value to be set
*/
public void setState(final String state);
/**
* set subRates
* @param subRates values to be set
*/
@JsonIgnore
public void setSubRates(final SubRate... subRates);
/**
* set subRates
* @param subRates values to be set
*/
public void setSubRates(final List subRates);
/**
* factory method
* @return instance of TaxRate
*/
public static TaxRate of() {
return new TaxRateImpl();
}
/**
* factory method to create a shallow copy TaxRate
* @param template instance to be copied
* @return copy instance
*/
public static TaxRate of(final TaxRate template) {
TaxRateImpl instance = new TaxRateImpl();
instance.setId(template.getId());
instance.setName(template.getName());
instance.setAmount(template.getAmount());
instance.setIncludedInPrice(template.getIncludedInPrice());
instance.setCountry(template.getCountry());
instance.setState(template.getState());
instance.setSubRates(template.getSubRates());
return instance;
}
/**
* factory method to create a deep copy of TaxRate
* @param template instance to be copied
* @return copy instance
*/
@Nullable
public static TaxRate deepCopy(@Nullable final TaxRate template) {
if (template == null) {
return null;
}
TaxRateImpl instance = new TaxRateImpl();
instance.setId(template.getId());
instance.setName(template.getName());
instance.setAmount(template.getAmount());
instance.setIncludedInPrice(template.getIncludedInPrice());
instance.setCountry(template.getCountry());
instance.setState(template.getState());
instance.setSubRates(Optional.ofNullable(template.getSubRates())
.map(t -> t.stream()
.map(com.commercetools.history.models.common.SubRate::deepCopy)
.collect(Collectors.toList()))
.orElse(null));
return instance;
}
/**
* builder factory method for TaxRate
* @return builder
*/
public static TaxRateBuilder builder() {
return TaxRateBuilder.of();
}
/**
* create builder for TaxRate instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static TaxRateBuilder builder(final TaxRate template) {
return TaxRateBuilder.of(template);
}
/**
* accessor map function
* @param mapped type
* @param helper function to map the object
* @return mapped value
*/
default T withTaxRate(Function helper) {
return helper.apply(this);
}
/**
* gives a TypeReference for usage with Jackson DataBind
* @return TypeReference
*/
public static com.fasterxml.jackson.core.type.TypeReference typeReference() {
return new com.fasterxml.jackson.core.type.TypeReference() {
@Override
public String toString() {
return "TypeReference";
}
};
}
}