Class PriceDraftBuilder

java.lang.Object
com.commercetools.api.models.common.PriceDraftBuilder
All Implemented Interfaces:
Builder<PriceDraft>

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

     PriceDraft priceDraft = PriceDraft.builder()
             .value(valueBuilder -> valueBuilder)
             .build()
 
  • Constructor Details

    • PriceDraftBuilder

      public PriceDraftBuilder()
  • Method Details

    • key

      User-defined identifier for the Price. It must be unique per ProductVariant.

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

      Money value of this Price.

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

      public PriceDraftBuilder withValue(Function<MoneyBuilder,Money> builder)

      Money value of this Price.

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

      public PriceDraftBuilder value(Money value)

      Money value of this Price.

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

      public PriceDraftBuilder country(@Nullable String country)

      Set this field if this Price is only valid for the specified country.

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

      Set this field if this Price is only valid for the referenced CustomerGroup.

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

      Set this field if this Price is only valid for the referenced CustomerGroup.

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

      public PriceDraftBuilder customerGroup(@Nullable CustomerGroupResourceIdentifier customerGroup)

      Set this field if this Price is only valid for the referenced CustomerGroup.

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

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

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

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

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

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

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

      public PriceDraftBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Set this field if this Price is only valid from the specified date and time. Must be at least 1 ms earlier than validUntil.

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

      public PriceDraftBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Set this field if this Price is only valid until the specified date and time. Must be at least 1 ms later than validFrom. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

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

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Parameters:
      builder - function to build the discounted value
      Returns:
      Builder
    • withDiscounted

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Parameters:
      builder - function to build the discounted value
      Returns:
      Builder
    • discounted

      public PriceDraftBuilder discounted(@Nullable DiscountedPriceDraft discounted)

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Parameters:
      discounted - value to be set
      Returns:
      Builder
    • tiers

      public PriceDraftBuilder tiers(@Nullable PriceTierDraft... tiers)

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      public PriceDraftBuilder plusTiers(@Nullable PriceTierDraft... tiers)

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

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

      Custom Fields for the Price.

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

      Custom Fields for the Price.

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

      Custom Fields for the Price.

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

      @Nullable public String getKey()

      User-defined identifier for the Price. It must be unique per ProductVariant.

      Returns:
      key
    • getValue

      public Money getValue()

      Money value of this Price.

      Returns:
      value
    • getCountry

      @Nullable public String getCountry()

      Set this field if this Price is only valid for the specified country.

      Returns:
      country
    • getCustomerGroup

      @Nullable public CustomerGroupResourceIdentifier getCustomerGroup()

      Set this field if this Price is only valid for the referenced CustomerGroup.

      Returns:
      customerGroup
    • getChannel

      @Nullable public ChannelResourceIdentifier getChannel()

      Set this field if this Price is only valid for the referenced ProductDistribution Channel.

      Returns:
      channel
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Set this field if this Price is only valid from the specified date and time. Must be at least 1 ms earlier than validUntil.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Set this field if this Price is only valid until the specified date and time. Must be at least 1 ms later than validFrom. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

      Returns:
      validUntil
    • getDiscounted

      @Nullable public DiscountedPriceDraft getDiscounted()

      Set this field to add a DiscountedPrice from an external service.

      Otherwise, Composable Commerce sets this field automatically if at least one ProductDiscount applies. The DiscountedPrice must reference a ProductDiscount with:

      • The isActive flag set to true.
      • A ProductDiscountValue of type external.
      • A predicate that matches the ProductVariant the Price is referenced from.
      Returns:
      discounted
    • getTiers

      @Nullable public List<PriceTierDraft> getTiers()

      Set this field to specify different Prices for certain LineItem quantities.

      If discounted is set, the tiered Price is ignored for a Product Variant.

      Returns:
      tiers
    • getCustom

      @Nullable public CustomFieldsDraft getCustom()

      Custom Fields for the Price.

      Returns:
      custom
    • build

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

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

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

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