Class LineItemImpl

java.lang.Object
com.commercetools.api.models.cart.LineItemImpl
All Implemented Interfaces:
LineItem, Customizable<LineItem>, io.vrap.rmf.base.client.ModelBase

public class LineItemImpl extends Object implements LineItem, io.vrap.rmf.base.client.ModelBase

The representation of a Line Item in a Cart.

  • Constructor Details

  • Method Details

    • getId

      public String getId()

      Unique identifier of the LineItem.

      Specified by:
      getId in interface LineItem
      Returns:
      id
    • getKey

      public String getKey()

      User-defined unique identifier of the LineItem.

      Specified by:
      getKey in interface LineItem
      Returns:
      key
    • getProductId

      public String getProductId()

      id of the Product the Line Item is based on.

      Specified by:
      getProductId in interface LineItem
      Returns:
      productId
    • getProductKey

      key of the Product.

      This field is only present on:

      • Line Items in a Cart when the key is available on that specific Product at the time the Line Item was created or updated on the Cart.
      • Orders when the key is available on the specific Product at the time the Order was created from the Cart.

      Present on resources created or updated after 3 December 2021.

      Specified by:
      getProductKey in interface LineItem
      Returns:
      productKey
    • getName

      Name of the Product.

      Specified by:
      getName in interface LineItem
      Returns:
      name
    • getProductSlug

      slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. The productSlug field of LineItem is not expanded when using Reference Expansion.

      Specified by:
      getProductSlug in interface LineItem
      Returns:
      productSlug
    • getProductType

      Product Type of the Product.

      Specified by:
      getProductType in interface LineItem
      Returns:
      productType
    • getVariant

      Holds the data of the Product Variant added to the Cart.

      The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. Must be updated using the Recalculate update action.

      Specified by:
      getVariant in interface LineItem
      Returns:
      variant
    • getPrice

      public Price getPrice()

      Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

      Specified by:
      getPrice in interface LineItem
      Returns:
      price
    • getQuantity

      public Long getQuantity()

      Number of Line Items of the given Product Variant present in the Cart.

      Specified by:
      getQuantity in interface LineItem
      Returns:
      quantity
    • getTotalPrice

      Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. Includes taxes if the TaxRate includedInPrice is true.

      Specified by:
      getTotalPrice in interface LineItem
      Returns:
      totalPrice
    • getDiscountedPricePerQuantity

      Discounted price of a single quantity of the Line Item.

      Specified by:
      getDiscountedPricePerQuantity in interface LineItem
      Returns:
      discountedPricePerQuantity
    • getTaxedPrice

      Automatically set after taxRate is set.

      Specified by:
      getTaxedPrice in interface LineItem
      Returns:
      taxedPrice
    • getTaxedPricePortions

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Specified by:
      getTaxedPricePortions in interface LineItem
      Returns:
      taxedPricePortions
    • getState

      public List<ItemState> getState()

      State of the Line Item in the Cart.

      Specified by:
      getState in interface LineItem
      Returns:
      state
    • getTaxRate

      public TaxRate getTaxRate()
      • For a Cart with Platform TaxMode, the taxRate of 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 Line Items can be set using ExternalTaxRateDraft.
      Specified by:
      getTaxRate in interface LineItem
      Returns:
      taxRate
    • 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.

      Specified by:
      getPerMethodTaxRate in interface LineItem
      Returns:
      perMethodTaxRate
    • getSupplyChannel

      Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

      Specified by:
      getSupplyChannel in interface LineItem
      Returns:
      supplyChannel
    • getDistributionChannel

      Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

      Specified by:
      getDistributionChannel in interface LineItem
      Returns:
      distributionChannel
    • getPriceMode

      Indicates how the Price for the Line Item is set.

      Specified by:
      getPriceMode in interface LineItem
      Returns:
      priceMode
    • getLineItemMode

      Indicates how the Line Item is added to the Cart.

      Specified by:
      getLineItemMode in interface LineItem
      Returns:
      lineItemMode
    • getInventoryMode

      Inventory mode specific to this Line Item only, and valid for the entire quantity of the Line Item. Only present if the inventory mode is different from the inventoryMode specified on the Cart.

      Specified by:
      getInventoryMode in interface LineItem
      Returns:
      inventoryMode
    • getShippingDetails

      Container for Line Item-specific addresses.

      Specified by:
      getShippingDetails in interface LineItem
      Returns:
      shippingDetails
    • getCustom

      Custom Fields of the Line Item.

      Specified by:
      getCustom in interface Customizable<LineItem>
      Specified by:
      getCustom in interface LineItem
      Returns:
      custom
    • getAddedAt

      Date and time (UTC) the Line Item was added to the Cart.

      Specified by:
      getAddedAt in interface LineItem
      Returns:
      addedAt
    • getLastModifiedAt

      Date and time (UTC) the Line Item was last updated.

      Specified by:
      getLastModifiedAt in interface LineItem
      Returns:
      lastModifiedAt
    • setId

      public void setId(String id)
      Description copied from interface: LineItem

      Unique identifier of the LineItem.

      Specified by:
      setId in interface LineItem
      Parameters:
      id - value to be set
    • setKey

      public void setKey(String key)
      Description copied from interface: LineItem

      User-defined unique identifier of the LineItem.

      Specified by:
      setKey in interface LineItem
      Parameters:
      key - value to be set
    • setProductId

      public void setProductId(String productId)
      Description copied from interface: LineItem

      id of the Product the Line Item is based on.

      Specified by:
      setProductId in interface LineItem
      Parameters:
      productId - value to be set
    • setProductKey

      public void setProductKey(String productKey)
      Description copied from interface: LineItem

      key of the Product.

      This field is only present on:

      • Line Items in a Cart when the key is available on that specific Product at the time the Line Item was created or updated on the Cart.
      • Orders when the key is available on the specific Product at the time the Order was created from the Cart.

      Present on resources created or updated after 3 December 2021.

      Specified by:
      setProductKey in interface LineItem
      Parameters:
      productKey - value to be set
    • setName

      public void setName(LocalizedString name)
      Description copied from interface: LineItem

      Name of the Product.

      Specified by:
      setName in interface LineItem
      Parameters:
      name - value to be set
    • setProductSlug

      public void setProductSlug(LocalizedString productSlug)
      Description copied from interface: LineItem

      slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. The productSlug field of LineItem is not expanded when using Reference Expansion.

      Specified by:
      setProductSlug in interface LineItem
      Parameters:
      productSlug - value to be set
    • setProductType

      public void setProductType(ProductTypeReference productType)
      Description copied from interface: LineItem

      Product Type of the Product.

      Specified by:
      setProductType in interface LineItem
      Parameters:
      productType - value to be set
    • setVariant

      public void setVariant(ProductVariant variant)
      Description copied from interface: LineItem

      Holds the data of the Product Variant added to the Cart.

      The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. Must be updated using the Recalculate update action.

      Specified by:
      setVariant in interface LineItem
      Parameters:
      variant - value to be set
    • setPrice

      public void setPrice(Price price)
      Description copied from interface: LineItem

      Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

      Specified by:
      setPrice in interface LineItem
      Parameters:
      price - value to be set
    • setQuantity

      public void setQuantity(Long quantity)
      Description copied from interface: LineItem

      Number of Line Items of the given Product Variant present in the Cart.

      Specified by:
      setQuantity in interface LineItem
      Parameters:
      quantity - value to be set
    • setTotalPrice

      public void setTotalPrice(CentPrecisionMoney totalPrice)
      Description copied from interface: LineItem

      Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. Includes taxes if the TaxRate includedInPrice is true.

      Specified by:
      setTotalPrice in interface LineItem
      Parameters:
      totalPrice - value to be set
    • setDiscountedPricePerQuantity

      public void setDiscountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity)
      Description copied from interface: LineItem

      Discounted price of a single quantity of the Line Item.

      Specified by:
      setDiscountedPricePerQuantity in interface LineItem
      Parameters:
      discountedPricePerQuantity - values to be set
    • setDiscountedPricePerQuantity

      public void setDiscountedPricePerQuantity(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity)
      Description copied from interface: LineItem

      Discounted price of a single quantity of the Line Item.

      Specified by:
      setDiscountedPricePerQuantity in interface LineItem
      Parameters:
      discountedPricePerQuantity - values to be set
    • setTaxedPrice

      public void setTaxedPrice(TaxedItemPrice taxedPrice)
      Description copied from interface: LineItem

      Automatically set after taxRate is set.

      Specified by:
      setTaxedPrice in interface LineItem
      Parameters:
      taxedPrice - value to be set
    • setTaxedPricePortions

      public void setTaxedPricePortions(MethodTaxedPrice... taxedPricePortions)
      Description copied from interface: LineItem

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Specified by:
      setTaxedPricePortions in interface LineItem
      Parameters:
      taxedPricePortions - values to be set
    • setTaxedPricePortions

      public void setTaxedPricePortions(List<MethodTaxedPrice> taxedPricePortions)
      Description copied from interface: LineItem

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Specified by:
      setTaxedPricePortions in interface LineItem
      Parameters:
      taxedPricePortions - values to be set
    • setState

      public void setState(ItemState... state)
      Description copied from interface: LineItem

      State of the Line Item in the Cart.

      Specified by:
      setState in interface LineItem
      Parameters:
      state - values to be set
    • setState

      public void setState(List<ItemState> state)
      Description copied from interface: LineItem

      State of the Line Item in the Cart.

      Specified by:
      setState in interface LineItem
      Parameters:
      state - values to be set
    • setTaxRate

      public void setTaxRate(TaxRate taxRate)
      Description copied from interface: LineItem
      • For a Cart with Platform TaxMode, the taxRate of 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 Line Items can be set using ExternalTaxRateDraft.
      Specified by:
      setTaxRate in interface LineItem
      Parameters:
      taxRate - value to be set
    • setPerMethodTaxRate

      public void setPerMethodTaxRate(MethodTaxRate... perMethodTaxRate)
      Description copied from interface: LineItem

      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.

      Specified by:
      setPerMethodTaxRate in interface LineItem
      Parameters:
      perMethodTaxRate - values to be set
    • setPerMethodTaxRate

      public void setPerMethodTaxRate(List<MethodTaxRate> perMethodTaxRate)
      Description copied from interface: LineItem

      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.

      Specified by:
      setPerMethodTaxRate in interface LineItem
      Parameters:
      perMethodTaxRate - values to be set
    • setSupplyChannel

      public void setSupplyChannel(ChannelReference supplyChannel)
      Description copied from interface: LineItem

      Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

      Specified by:
      setSupplyChannel in interface LineItem
      Parameters:
      supplyChannel - value to be set
    • setDistributionChannel

      public void setDistributionChannel(ChannelReference distributionChannel)
      Description copied from interface: LineItem

      Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

      Specified by:
      setDistributionChannel in interface LineItem
      Parameters:
      distributionChannel - value to be set
    • setPriceMode

      public void setPriceMode(LineItemPriceMode priceMode)
      Description copied from interface: LineItem

      Indicates how the Price for the Line Item is set.

      Specified by:
      setPriceMode in interface LineItem
      Parameters:
      priceMode - value to be set
    • setLineItemMode

      public void setLineItemMode(LineItemMode lineItemMode)
      Description copied from interface: LineItem

      Indicates how the Line Item is added to the Cart.

      Specified by:
      setLineItemMode in interface LineItem
      Parameters:
      lineItemMode - value to be set
    • setInventoryMode

      public void setInventoryMode(InventoryMode inventoryMode)
      Description copied from interface: LineItem

      Inventory mode specific to this Line Item only, and valid for the entire quantity of the Line Item. Only present if the inventory mode is different from the inventoryMode specified on the Cart.

      Specified by:
      setInventoryMode in interface LineItem
      Parameters:
      inventoryMode - value to be set
    • setShippingDetails

      public void setShippingDetails(ItemShippingDetails shippingDetails)
      Description copied from interface: LineItem

      Container for Line Item-specific addresses.

      Specified by:
      setShippingDetails in interface LineItem
      Parameters:
      shippingDetails - value to be set
    • setCustom

      public void setCustom(CustomFields custom)
      Description copied from interface: LineItem

      Custom Fields of the Line Item.

      Specified by:
      setCustom in interface Customizable<LineItem>
      Specified by:
      setCustom in interface LineItem
      Parameters:
      custom - value to be set
    • setAddedAt

      public void setAddedAt(ZonedDateTime addedAt)
      Description copied from interface: LineItem

      Date and time (UTC) the Line Item was added to the Cart.

      Specified by:
      setAddedAt in interface LineItem
      Parameters:
      addedAt - value to be set
    • setLastModifiedAt

      public void setLastModifiedAt(ZonedDateTime lastModifiedAt)
      Description copied from interface: LineItem

      Date and time (UTC) the Line Item was last updated.

      Specified by:
      setLastModifiedAt in interface LineItem
      Parameters:
      lastModifiedAt - value to be set
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object