001 002package com.commercetools.api.models.shipping_method; 003 004import java.time.*; 005import java.util.*; 006 007import com.fasterxml.jackson.annotation.JsonCreator; 008import com.fasterxml.jackson.annotation.JsonProperty; 009import com.fasterxml.jackson.databind.annotation.*; 010 011import io.vrap.rmf.base.client.ModelBase; 012import io.vrap.rmf.base.client.utils.Generated; 013 014import org.apache.commons.lang3.builder.EqualsBuilder; 015import org.apache.commons.lang3.builder.HashCodeBuilder; 016 017/** 018 * PriceFunction 019 */ 020@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 021public class PriceFunctionImpl implements PriceFunction, ModelBase { 022 023 private String currencyCode; 024 025 private String function; 026 027 /** 028 * create instance with all properties 029 */ 030 @JsonCreator 031 PriceFunctionImpl(@JsonProperty("currencyCode") final String currencyCode, 032 @JsonProperty("function") final String function) { 033 this.currencyCode = currencyCode; 034 this.function = function; 035 } 036 037 /** 038 * create empty instance 039 */ 040 public PriceFunctionImpl() { 041 } 042 043 /** 044 * <p>Currency code compliant to ISO 4217.</p> 045 */ 046 047 public String getCurrencyCode() { 048 return this.currencyCode; 049 } 050 051 /** 052 * <p>To calculate a Price based on the score, use <code>+</code>, <code>-</code>, <code>*</code> and parentheses. The score is inserted with <code>x</code>. The function returns the cent amount.</p> 053 * <p>For example, to charge $1.99 for a score of <code>1</code>, $3.99 for a score of <code>2</code>, $5.99 for a score of <code>3</code> and onwards, the function is: <code>(200 * x) - 1)</code>. To charge $4.50, $6.00, and $7.50 for express shipping, the function is: <code>(150 * x) + 300</code>.</p> 054 */ 055 056 public String getFunction() { 057 return this.function; 058 } 059 060 public void setCurrencyCode(final String currencyCode) { 061 this.currencyCode = currencyCode; 062 } 063 064 public void setFunction(final String function) { 065 this.function = function; 066 } 067 068 @Override 069 public boolean equals(Object o) { 070 if (this == o) 071 return true; 072 073 if (o == null || getClass() != o.getClass()) 074 return false; 075 076 PriceFunctionImpl that = (PriceFunctionImpl) o; 077 078 return new EqualsBuilder().append(currencyCode, that.currencyCode).append(function, that.function).isEquals(); 079 } 080 081 @Override 082 public int hashCode() { 083 return new HashCodeBuilder(17, 37).append(currencyCode).append(function).toHashCode(); 084 } 085 086}