Class PriceFunctionBuilder

java.lang.Object
com.commercetools.api.models.shipping_method.PriceFunctionBuilder
All Implemented Interfaces:
Builder<PriceFunction>

public class PriceFunctionBuilder extends Object implements Builder<PriceFunction>
PriceFunctionBuilder
Example to create an instance using the builder pattern

     PriceFunction priceFunction = PriceFunction.builder()
             .currencyCode("{currencyCode}")
             .function("{function}")
             .build()
 
  • Constructor Details

    • PriceFunctionBuilder

      public PriceFunctionBuilder()
  • Method Details

    • currencyCode

      public PriceFunctionBuilder currencyCode(String currencyCode)

      Currency code compliant to ISO 4217.

      Parameters:
      currencyCode - value to be set
      Returns:
      Builder
    • function

      public PriceFunctionBuilder function(String function)

      To calculate a Price based on the score, use +, -, * and parentheses. The score is inserted with x. The function returns the cent amount.

      For example, to charge $1.99 for a score of 1, $3.99 for a score of 2, $5.99 for a score of 3 and onwards, the function is: (200 * x) - 1). To charge $4.50, $6.00, and $7.50 for express shipping, the function is: (150 * x) + 300.

      Parameters:
      function - value to be set
      Returns:
      Builder
    • getCurrencyCode

      public String getCurrencyCode()

      Currency code compliant to ISO 4217.

      Returns:
      currencyCode
    • getFunction

      public String getFunction()

      To calculate a Price based on the score, use +, -, * and parentheses. The score is inserted with x. The function returns the cent amount.

      For example, to charge $1.99 for a score of 1, $3.99 for a score of 2, $5.99 for a score of 3 and onwards, the function is: (200 * x) - 1). To charge $4.50, $6.00, and $7.50 for express shipping, the function is: (150 * x) + 300.

      Returns:
      function
    • build

      public PriceFunction build()
      builds PriceFunction with checking for non-null required values
      Specified by:
      build in interface Builder<PriceFunction>
      Returns:
      PriceFunction
    • buildUnchecked

      public PriceFunction buildUnchecked()
      builds PriceFunction without checking for non-null required values
      Returns:
      PriceFunction
    • of

      public static PriceFunctionBuilder of()
      factory method for an instance of PriceFunctionBuilder
      Returns:
      builder
    • of

      public static PriceFunctionBuilder of(PriceFunction template)
      create builder for PriceFunction instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder