Class PriceBuilder

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

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

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

    • PriceBuilder

      public PriceBuilder()
  • Method Details

    • id

      public PriceBuilder id(String id)

      Unique identifier of this Price.

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

      public PriceBuilder key(@Nullable String key)

      User-defined identifier of the Price. It is unique per ProductVariant.

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

      public PriceBuilder value(TypedMoney value)

      Money value of this Price.

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

      public PriceBuilder value(Function<TypedMoneyBuilder,Builder<? extends TypedMoney>> builder)

      Money value of this Price.

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

      public PriceBuilder country(@Nullable String country)

      Country for which this Price is valid.

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

      CustomerGroup for which this Price is valid.

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

      CustomerGroup for which this Price is valid.

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

      public PriceBuilder customerGroup(@Nullable CustomerGroupReference customerGroup)

      CustomerGroup for which this Price is valid.

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

      ProductDistribution Channel for which this Price is valid.

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

      ProductDistribution Channel for which this Price is valid.

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

      public PriceBuilder channel(@Nullable ChannelReference channel)

      ProductDistribution Channel for which this Price is valid.

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

      public PriceBuilder validFrom(@Nullable ZonedDateTime validFrom)

      Date and time from which this Price is valid.

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

      public PriceBuilder validUntil(@Nullable ZonedDateTime validUntil)

      Date and time until this Price is valid. 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

      Is set if a ProductDiscount has been applied. If set, the API uses the DiscountedPrice value for the Line Item price selection. When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

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

      public PriceBuilder withDiscounted(Function<DiscountedPriceBuilder,DiscountedPrice> builder)

      Is set if a ProductDiscount has been applied. If set, the API uses the DiscountedPrice value for the Line Item price selection. When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

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

      public PriceBuilder discounted(@Nullable DiscountedPrice discounted)

      Is set if a ProductDiscount has been applied. If set, the API uses the DiscountedPrice value for the Line Item price selection. When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

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

      public PriceBuilder tiers(@Nullable PriceTier... tiers)

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      public PriceBuilder tiers(@Nullable List<PriceTier> tiers)

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      public PriceBuilder plusTiers(@Nullable PriceTier... tiers)

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      public PriceBuilder addTiers(Function<PriceTierBuilder,PriceTier> builder)

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      public PriceBuilder setTiers(Function<PriceTierBuilder,PriceTier> builder)

      Present if different Prices for certain LineItem quantities have been specified.

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

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

      Custom Fields defined for the Price.

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

      public PriceBuilder withCustom(Function<CustomFieldsBuilder,CustomFields> builder)

      Custom Fields defined for the Price.

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

      public PriceBuilder custom(@Nullable CustomFields custom)

      Custom Fields defined for the Price.

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

      public String getId()

      Unique identifier of this Price.

      Returns:
      id
    • getKey

      @Nullable public String getKey()

      User-defined identifier of the Price. It is unique per ProductVariant.

      Returns:
      key
    • getValue

      public TypedMoney getValue()

      Money value of this Price.

      Returns:
      value
    • getCountry

      @Nullable public String getCountry()

      Country for which this Price is valid.

      Returns:
      country
    • getCustomerGroup

      @Nullable public CustomerGroupReference getCustomerGroup()

      CustomerGroup for which this Price is valid.

      Returns:
      customerGroup
    • getChannel

      @Nullable public ChannelReference getChannel()

      ProductDistribution Channel for which this Price is valid.

      Returns:
      channel
    • getValidFrom

      @Nullable public ZonedDateTime getValidFrom()

      Date and time from which this Price is valid.

      Returns:
      validFrom
    • getValidUntil

      @Nullable public ZonedDateTime getValidUntil()

      Date and time until this Price is valid. Prices that are no longer valid are not automatically removed, but they can be removed if necessary.

      Returns:
      validUntil
    • getDiscounted

      @Nullable public DiscountedPrice getDiscounted()

      Is set if a ProductDiscount has been applied. If set, the API uses the DiscountedPrice value for the Line Item price selection. When a relative discount has been applied and the fraction part of the DiscountedPrice value is 0.5, the value is rounded in favor of the customer with half-down rounding.

      Returns:
      discounted
    • getTiers

      @Nullable public List<PriceTier> getTiers()

      Present if different Prices for certain LineItem quantities have been specified.

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

      Returns:
      tiers
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields defined for the Price.

      Returns:
      custom
    • build

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

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

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

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