Class DirectDiscountBuilder

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

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

     DirectDiscount directDiscount = DirectDiscount.builder()
             .id("{id}")
             .value(valueBuilder -> valueBuilder)
             .build()
 
  • Constructor Details

    • DirectDiscountBuilder

      public DirectDiscountBuilder()
  • Method Details

    • id

      public DirectDiscountBuilder id(String id)

      Unique identifier of the Direct Discount.

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

      Effect of the Discount on the Cart.

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

      Effect of the Discount on the Cart.

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

      public DirectDiscountBuilder target(@Nullable CartDiscountTarget target)

      Segment of the Cart that is discounted.

      Absent if the value is giftLineItem.

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

      Segment of the Cart that is discounted.

      Absent if the value is giftLineItem.

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

      public DirectDiscountBuilder participateInBestDealSelection(@Nullable Boolean participateInBestDealSelection)
      • If true, Direct Discounts compete against Product Discounts to apply the best deal.
      • If false, Direct Discounts are ignored when calculating the best deal comparison, and are applied on top of the discount type that offers the best deal.

      This applies only when the DiscountCombinationMode for the Project is BestDeal.

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

      public String getId()

      Unique identifier of the Direct Discount.

      Returns:
      id
    • getValue

      public CartDiscountValue getValue()

      Effect of the Discount on the Cart.

      Returns:
      value
    • getTarget

      @Nullable public CartDiscountTarget getTarget()

      Segment of the Cart that is discounted.

      Absent if the value is giftLineItem.

      Returns:
      target
    • getParticipateInBestDealSelection

      @Nullable public Boolean getParticipateInBestDealSelection()
      • If true, Direct Discounts compete against Product Discounts to apply the best deal.
      • If false, Direct Discounts are ignored when calculating the best deal comparison, and are applied on top of the discount type that offers the best deal.

      This applies only when the DiscountCombinationMode for the Project is BestDeal.

      Returns:
      participateInBestDealSelection
    • build

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

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

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

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