Class LineItemDraftBuilder

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

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

     LineItemDraft lineItemDraft = LineItemDraft.builder()
             .build()
 
  • Constructor Details

    • LineItemDraftBuilder

      public LineItemDraftBuilder()
  • Method Details

    • key

      User-defined unique identifier of the LineItem.

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

      public LineItemDraftBuilder productId(@Nullable String productId)

      id of a published Product.

      Parameters:
      productId - value to be set
      Returns:
      Builder
    • variantId

      public LineItemDraftBuilder variantId(@Nullable Long variantId)

      id of the ProductVariant in the Product. If not provided, the Master Variant is used.

      Parameters:
      variantId - value to be set
      Returns:
      Builder
    • sku

      sku of the ProductVariant.

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

      public LineItemDraftBuilder quantity(@Nullable Long quantity)

      Quantity of the Product Variant to add to the Cart.

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

      public LineItemDraftBuilder addedAt(@Nullable ZonedDateTime addedAt)

      Date and time (UTC) the Product Variant is added to the Cart. If not set, it defaults to the current date and time.

      Optional for backwards compatibility reasons.

      Parameters:
      addedAt - value to be set
      Returns:
      Builder
    • distributionChannel

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

      If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.

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

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

      If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.

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

      public LineItemDraftBuilder distributionChannel(@Nullable ChannelResourceIdentifier distributionChannel)

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

      If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.

      Parameters:
      distributionChannel - value to be set
      Returns:
      Builder
    • supplyChannel

      Used to identify Inventory entries that must be reserved. The referenced Channel must have the InventorySupply ChannelRoleEnum.

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

      Used to identify Inventory entries that must be reserved. The referenced Channel must have the InventorySupply ChannelRoleEnum.

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

      public LineItemDraftBuilder supplyChannel(@Nullable ChannelResourceIdentifier supplyChannel)

      Used to identify Inventory entries that must be reserved. The referenced Channel must have the InventorySupply ChannelRoleEnum.

      Parameters:
      supplyChannel - value to be set
      Returns:
      Builder
    • externalPrice

      public LineItemDraftBuilder externalPrice(Function<MoneyBuilder,MoneyBuilder> builder)

      Sets the LineItem price value, and the priceMode to ExternalPrice LineItemPriceMode.

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

      public LineItemDraftBuilder withExternalPrice(Function<MoneyBuilder,Money> builder)

      Sets the LineItem price value, and the priceMode to ExternalPrice LineItemPriceMode.

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

      public LineItemDraftBuilder externalPrice(@Nullable Money externalPrice)

      Sets the LineItem price value, and the priceMode to ExternalPrice LineItemPriceMode.

      Parameters:
      externalPrice - value to be set
      Returns:
      Builder
    • externalTotalPrice

      Sets the LineItem price and totalPrice values, and the priceMode to ExternalTotal LineItemPriceMode.

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

      Sets the LineItem price and totalPrice values, and the priceMode to ExternalTotal LineItemPriceMode.

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

      public LineItemDraftBuilder externalTotalPrice(@Nullable ExternalLineItemTotalPrice externalTotalPrice)

      Sets the LineItem price and totalPrice values, and the priceMode to ExternalTotal LineItemPriceMode.

      Parameters:
      externalTotalPrice - value to be set
      Returns:
      Builder
    • externalTaxRate

      Sets the external Tax Rate for the Line Item, if the Cart has the External TaxMode and Single ShippingMode. If the Cart has Multiple ShippingMode, the Tax Rate is accepted but ignored.

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

      Sets the external Tax Rate for the Line Item, if the Cart has the External TaxMode and Single ShippingMode. If the Cart has Multiple ShippingMode, the Tax Rate is accepted but ignored.

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

      public LineItemDraftBuilder externalTaxRate(@Nullable ExternalTaxRateDraft externalTaxRate)

      Sets the external Tax Rate for the Line Item, if the Cart has the External TaxMode and Single ShippingMode. If the Cart has Multiple ShippingMode, the Tax Rate is accepted but ignored.

      Parameters:
      externalTaxRate - value to be set
      Returns:
      Builder
    • perMethodExternalTaxRate

      public LineItemDraftBuilder perMethodExternalTaxRate(@Nullable MethodExternalTaxRateDraft... perMethodExternalTaxRate)

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

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

      public LineItemDraftBuilder perMethodExternalTaxRate(@Nullable List<MethodExternalTaxRateDraft> perMethodExternalTaxRate)

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

      Parameters:
      perMethodExternalTaxRate - value to be set
      Returns:
      Builder
    • plusPerMethodExternalTaxRate

      public LineItemDraftBuilder plusPerMethodExternalTaxRate(@Nullable MethodExternalTaxRateDraft... perMethodExternalTaxRate)

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

      Parameters:
      perMethodExternalTaxRate - value to be set
      Returns:
      Builder
    • plusPerMethodExternalTaxRate

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

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

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

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

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

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

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

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

      public LineItemDraftBuilder inventoryMode(@Nullable InventoryMode inventoryMode)

      Inventory mode specific to the Line Item only, and valid for the entire quantity of the Line Item. Set only if the inventory mode should be different from the inventoryMode specified on the Cart.

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

      Container for Line Item-specific addresses.

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

      Container for Line Item-specific addresses.

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

      public LineItemDraftBuilder shippingDetails(@Nullable ItemShippingDetailsDraft shippingDetails)

      Container for Line Item-specific addresses.

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

      Custom Fields for the Line Item.

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

      Custom Fields for the Line Item.

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

      Custom Fields for the Line Item.

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

      @Nullable public String getKey()

      User-defined unique identifier of the LineItem.

      Returns:
      key
    • getProductId

      @Nullable public String getProductId()

      id of a published Product.

      Returns:
      productId
    • getVariantId

      @Nullable public Long getVariantId()

      id of the ProductVariant in the Product. If not provided, the Master Variant is used.

      Returns:
      variantId
    • getSku

      @Nullable public String getSku()

      sku of the ProductVariant.

      Returns:
      sku
    • getQuantity

      @Nullable public Long getQuantity()

      Quantity of the Product Variant to add to the Cart.

      Returns:
      quantity
    • getAddedAt

      @Nullable public ZonedDateTime getAddedAt()

      Date and time (UTC) the Product Variant is added to the Cart. If not set, it defaults to the current date and time.

      Optional for backwards compatibility reasons.

      Returns:
      addedAt
    • getDistributionChannel

      @Nullable public ChannelResourceIdentifier getDistributionChannel()

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

      If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.

      Returns:
      distributionChannel
    • getSupplyChannel

      @Nullable public ChannelResourceIdentifier getSupplyChannel()

      Used to identify Inventory entries that must be reserved. The referenced Channel must have the InventorySupply ChannelRoleEnum.

      Returns:
      supplyChannel
    • getExternalPrice

      @Nullable public Money getExternalPrice()

      Sets the LineItem price value, and the priceMode to ExternalPrice LineItemPriceMode.

      Returns:
      externalPrice
    • getExternalTotalPrice

      @Nullable public ExternalLineItemTotalPrice getExternalTotalPrice()

      Sets the LineItem price and totalPrice values, and the priceMode to ExternalTotal LineItemPriceMode.

      Returns:
      externalTotalPrice
    • getExternalTaxRate

      @Nullable public ExternalTaxRateDraft getExternalTaxRate()

      Sets the external Tax Rate for the Line Item, if the Cart has the External TaxMode and Single ShippingMode. If the Cart has Multiple ShippingMode, the Tax Rate is accepted but ignored.

      Returns:
      externalTaxRate
    • getPerMethodExternalTaxRate

      @Nullable public List<MethodExternalTaxRateDraft> getPerMethodExternalTaxRate()

      Sets the external Tax Rates for individual Shipping Methods, if the Cart has the External TaxMode and Multiple ShippingMode.

      Returns:
      perMethodExternalTaxRate
    • getInventoryMode

      @Nullable public InventoryMode getInventoryMode()

      Inventory mode specific to the Line Item only, and valid for the entire quantity of the Line Item. Set only if the inventory mode should be different from the inventoryMode specified on the Cart.

      Returns:
      inventoryMode
    • getShippingDetails

      @Nullable public ItemShippingDetailsDraft getShippingDetails()

      Container for Line Item-specific addresses.

      Returns:
      shippingDetails
    • getCustom

      @Nullable public CustomFieldsDraft getCustom()

      Custom Fields for the Line Item.

      Returns:
      custom
    • build

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

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

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

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