Class CustomLineItemBuilder

java.lang.Object
com.commercetools.api.models.cart.CustomLineItemBuilder
All Implemented Interfaces:
Builder<CustomLineItem>

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

     CustomLineItem customLineItem = CustomLineItem.builder()
             .id("{id}")
             .name(nameBuilder -> nameBuilder)
             .money(moneyBuilder -> moneyBuilder)
             .plusTaxedPricePortions(taxedPricePortionsBuilder -> taxedPricePortionsBuilder)
             .totalPrice(totalPriceBuilder -> totalPriceBuilder)
             .slug("{slug}")
             .quantity(0.3)
             .plusState(stateBuilder -> stateBuilder)
             .plusPerMethodTaxRate(perMethodTaxRateBuilder -> perMethodTaxRateBuilder)
             .plusDiscountedPricePerQuantity(discountedPricePerQuantityBuilder -> discountedPricePerQuantityBuilder)
             .priceMode(CustomLineItemPriceMode.STANDARD)
             .build()
 
  • Constructor Details

    • CustomLineItemBuilder

      public CustomLineItemBuilder()
  • Method Details

    • id

      public CustomLineItemBuilder id(String id)

      Unique identifier of the Custom Line Item.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • key

      User-defined unique identifier of the Custom Line Item.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • name

      Name of the Custom Line Item.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • withName

      Name of the Custom Line Item.

      Parameters:
      builder - function to build the name value
      Returns:
      Builder
    • name

      Name of the Custom Line Item.

      Parameters:
      name - value to be set
      Returns:
      Builder
    • money

      public CustomLineItemBuilder money(TypedMoney money)

      Money value of the Custom Line Item.

      Parameters:
      money - value to be set
      Returns:
      Builder
    • money

      Money value of the Custom Line Item.

      Parameters:
      builder - function to build the money value
      Returns:
      Builder
    • taxedPrice

      Automatically set after the taxRate is set.

      Parameters:
      builder - function to build the taxedPrice value
      Returns:
      Builder
    • withTaxedPrice

      Automatically set after the taxRate is set.

      Parameters:
      builder - function to build the taxedPrice value
      Returns:
      Builder
    • taxedPrice

      public CustomLineItemBuilder taxedPrice(@Nullable TaxedItemPrice taxedPrice)

      Automatically set after the taxRate is set.

      Parameters:
      taxedPrice - value to be set
      Returns:
      Builder
    • taxedPricePortions

      public CustomLineItemBuilder taxedPricePortions(MethodTaxedPrice... taxedPricePortions)

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - value to be set
      Returns:
      Builder
    • taxedPricePortions

      public CustomLineItemBuilder taxedPricePortions(List<MethodTaxedPrice> taxedPricePortions)

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - value to be set
      Returns:
      Builder
    • plusTaxedPricePortions

      public CustomLineItemBuilder plusTaxedPricePortions(MethodTaxedPrice... taxedPricePortions)

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - value to be set
      Returns:
      Builder
    • plusTaxedPricePortions

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      builder - function to build the taxedPricePortions value
      Returns:
      Builder
    • withTaxedPricePortions

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      builder - function to build the taxedPricePortions value
      Returns:
      Builder
    • addTaxedPricePortions

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      builder - function to build the taxedPricePortions value
      Returns:
      Builder
    • setTaxedPricePortions

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      builder - function to build the taxedPricePortions value
      Returns:
      Builder
    • totalPrice

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Parameters:
      builder - function to build the totalPrice value
      Returns:
      Builder
    • withTotalPrice

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Parameters:
      builder - function to build the totalPrice value
      Returns:
      Builder
    • totalPrice

      public CustomLineItemBuilder totalPrice(CentPrecisionMoney totalPrice)

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Parameters:
      totalPrice - value to be set
      Returns:
      Builder
    • slug

      public CustomLineItemBuilder slug(String slug)

      User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern [a-zA-Z0-9_-]{2,256}.

      Parameters:
      slug - value to be set
      Returns:
      Builder
    • quantity

      public CustomLineItemBuilder quantity(Long quantity)

      Number of Custom Line Items in the Cart or Order.

      Parameters:
      quantity - value to be set
      Returns:
      Builder
    • state

      public CustomLineItemBuilder state(ItemState... state)

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • state

      public CustomLineItemBuilder state(List<ItemState> state)

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • plusState

      public CustomLineItemBuilder plusState(ItemState... state)

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • plusState

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      builder - function to build the state value
      Returns:
      Builder
    • withState

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      builder - function to build the state value
      Returns:
      Builder
    • addState

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      builder - function to build the state value
      Returns:
      Builder
    • setState

      State of the Custom Line Item in the Cart or Order.

      Parameters:
      builder - function to build the state value
      Returns:
      Builder
    • taxCategory

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Parameters:
      builder - function to build the taxCategory value
      Returns:
      Builder
    • withTaxCategory

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Parameters:
      builder - function to build the taxCategory value
      Returns:
      Builder
    • taxCategory

      public CustomLineItemBuilder taxCategory(@Nullable TaxCategoryReference taxCategory)

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Parameters:
      taxCategory - value to be set
      Returns:
      Builder
    • taxRate

      • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
      • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
      Parameters:
      builder - function to build the taxRate value
      Returns:
      Builder
    • withTaxRate

      public CustomLineItemBuilder withTaxRate(Function<TaxRateBuilder,TaxRate> builder)
      • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
      • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
      Parameters:
      builder - function to build the taxRate value
      Returns:
      Builder
    • taxRate

      public CustomLineItemBuilder taxRate(@Nullable TaxRate taxRate)
      • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
      • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
      Parameters:
      taxRate - value to be set
      Returns:
      Builder
    • perMethodTaxRate

      public CustomLineItemBuilder perMethodTaxRate(MethodTaxRate... perMethodTaxRate)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      perMethodTaxRate - value to be set
      Returns:
      Builder
    • perMethodTaxRate

      public CustomLineItemBuilder perMethodTaxRate(List<MethodTaxRate> perMethodTaxRate)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      perMethodTaxRate - value to be set
      Returns:
      Builder
    • plusPerMethodTaxRate

      public CustomLineItemBuilder plusPerMethodTaxRate(MethodTaxRate... perMethodTaxRate)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      perMethodTaxRate - value to be set
      Returns:
      Builder
    • plusPerMethodTaxRate

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      builder - function to build the perMethodTaxRate value
      Returns:
      Builder
    • withPerMethodTaxRate

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      builder - function to build the perMethodTaxRate value
      Returns:
      Builder
    • addPerMethodTaxRate

      public CustomLineItemBuilder addPerMethodTaxRate(Function<MethodTaxRateBuilder,MethodTaxRate> builder)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      builder - function to build the perMethodTaxRate value
      Returns:
      Builder
    • setPerMethodTaxRate

      public CustomLineItemBuilder setPerMethodTaxRate(Function<MethodTaxRateBuilder,MethodTaxRate> builder)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      builder - function to build the perMethodTaxRate value
      Returns:
      Builder
    • discountedPricePerQuantity

      public CustomLineItemBuilder discountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity)

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      discountedPricePerQuantity - value to be set
      Returns:
      Builder
    • discountedPricePerQuantity

      public CustomLineItemBuilder discountedPricePerQuantity(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity)

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      discountedPricePerQuantity - value to be set
      Returns:
      Builder
    • plusDiscountedPricePerQuantity

      public CustomLineItemBuilder plusDiscountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity)

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      discountedPricePerQuantity - value to be set
      Returns:
      Builder
    • plusDiscountedPricePerQuantity

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      builder - function to build the discountedPricePerQuantity value
      Returns:
      Builder
    • withDiscountedPricePerQuantity

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      builder - function to build the discountedPricePerQuantity value
      Returns:
      Builder
    • addDiscountedPricePerQuantity

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      builder - function to build the discountedPricePerQuantity value
      Returns:
      Builder
    • setDiscountedPricePerQuantity

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      builder - function to build the discountedPricePerQuantity value
      Returns:
      Builder
    • custom

      Custom Fields of the Custom Line Item.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      Custom Fields of the Custom Line Item.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      Custom Fields of the Custom Line Item.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • shippingDetails

      Container for Custom Line Item-specific addresses.

      Parameters:
      builder - function to build the shippingDetails value
      Returns:
      Builder
    • withShippingDetails

      Container for Custom Line Item-specific addresses.

      Parameters:
      builder - function to build the shippingDetails value
      Returns:
      Builder
    • shippingDetails

      public CustomLineItemBuilder shippingDetails(@Nullable ItemShippingDetails shippingDetails)

      Container for Custom Line Item-specific addresses.

      Parameters:
      shippingDetails - value to be set
      Returns:
      Builder
    • priceMode

      public CustomLineItemBuilder priceMode(CustomLineItemPriceMode priceMode)

      Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.

      Parameters:
      priceMode - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Custom Line Item.

      Returns:
      id
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the Custom Line Item.

      Returns:
      key
    • getName

      public LocalizedString getName()

      Name of the Custom Line Item.

      Returns:
      name
    • getMoney

      public TypedMoney getMoney()

      Money value of the Custom Line Item.

      Returns:
      money
    • getTaxedPrice

      @Nullable public TaxedItemPrice getTaxedPrice()

      Automatically set after the taxRate is set.

      Returns:
      taxedPrice
    • getTaxedPricePortions

      public List<MethodTaxedPrice> getTaxedPricePortions()

      Total taxed prices based on the quantity of the Custom Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Returns:
      taxedPricePortions
    • getTotalPrice

      public CentPrecisionMoney getTotalPrice()

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Returns:
      totalPrice
    • getSlug

      public String getSlug()

      User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern [a-zA-Z0-9_-]{2,256}.

      Returns:
      slug
    • getQuantity

      public Long getQuantity()

      Number of Custom Line Items in the Cart or Order.

      Returns:
      quantity
    • getState

      public List<ItemState> getState()

      State of the Custom Line Item in the Cart or Order.

      Returns:
      state
    • getTaxCategory

      @Nullable public TaxCategoryReference getTaxCategory()

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Returns:
      taxCategory
    • getTaxRate

      @Nullable public TaxRate getTaxRate()
      • For a Cart with Platform TaxMode, the taxRate of Custom Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address.
      • For a Cart with External TaxMode, the taxRate of Custom Line Items can be set using ExternalTaxRateDraft.
      Returns:
      taxRate
    • getPerMethodTaxRate

      public List<MethodTaxRate> getPerMethodTaxRate()

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Returns:
      perMethodTaxRate
    • getDiscountedPricePerQuantity

      public List<DiscountedLineItemPriceForQuantity> getDiscountedPricePerQuantity()

      Discounted price of a single quantity of the Custom Line Item.

      Returns:
      discountedPricePerQuantity
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields of the Custom Line Item.

      Returns:
      custom
    • getShippingDetails

      @Nullable public ItemShippingDetails getShippingDetails()

      Container for Custom Line Item-specific addresses.

      Returns:
      shippingDetails
    • getPriceMode

      public CustomLineItemPriceMode getPriceMode()

      Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.

      Returns:
      priceMode
    • build

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

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

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

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