Class ProductVariantBuilder

java.lang.Object
com.commercetools.api.models.product.ProductVariantBuilder
All Implemented Interfaces:
Builder<ProductVariant>

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

     ProductVariant productVariant = ProductVariant.builder()
             .id(0.3)
             .build()
 
  • Constructor Details

    • ProductVariantBuilder

      public ProductVariantBuilder()
  • Method Details

    • id

      public ProductVariantBuilder id(Long id)

      A unique, sequential identifier of the Product Variant within the Product.

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

      User-defined unique SKU of the Product Variant.

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

      User-defined unique identifier of the ProductVariant.

      This is different from Product key.

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

      public ProductVariantBuilder prices(@Nullable Price... prices)

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      public ProductVariantBuilder prices(@Nullable List<Price> prices)

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      public ProductVariantBuilder plusPrices(@Nullable Price... prices)

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      public ProductVariantBuilder addPrices(Function<PriceBuilder,Price> builder)

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      public ProductVariantBuilder setPrices(Function<PriceBuilder,Price> builder)

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

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

      public ProductVariantBuilder attributes(@Nullable Attribute... attributes)

      Attributes of the Product Variant.

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

      public ProductVariantBuilder attributes(@Nullable List<Attribute> attributes)

      Attributes of the Product Variant.

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

      public ProductVariantBuilder plusAttributes(@Nullable Attribute... attributes)

      Attributes of the Product Variant.

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

      Attributes of the Product Variant.

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

      Attributes of the Product Variant.

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

      public ProductVariantBuilder addAttributes(Function<AttributeBuilder,Attribute> builder)

      Attributes of the Product Variant.

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

      public ProductVariantBuilder setAttributes(Function<AttributeBuilder,Attribute> builder)

      Attributes of the Product Variant.

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

      Only available when price selection is used. Cannot be used in a Query Predicate.

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

      public ProductVariantBuilder withPrice(Function<PriceBuilder,Price> builder)

      Only available when price selection is used. Cannot be used in a Query Predicate.

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

      public ProductVariantBuilder price(@Nullable Price price)

      Only available when price selection is used. Cannot be used in a Query Predicate.

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

      public ProductVariantBuilder images(@Nullable Image... images)

      Images of the Product Variant.

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

      public ProductVariantBuilder images(@Nullable List<Image> images)

      Images of the Product Variant.

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

      public ProductVariantBuilder plusImages(@Nullable Image... images)

      Images of the Product Variant.

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

      Images of the Product Variant.

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

      Images of the Product Variant.

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

      public ProductVariantBuilder addImages(Function<ImageBuilder,Image> builder)

      Images of the Product Variant.

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

      public ProductVariantBuilder setImages(Function<ImageBuilder,Image> builder)

      Images of the Product Variant.

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

      public ProductVariantBuilder assets(@Nullable Asset... assets)

      Media assets of the Product Variant.

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

      public ProductVariantBuilder assets(@Nullable List<Asset> assets)

      Media assets of the Product Variant.

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

      public ProductVariantBuilder plusAssets(@Nullable Asset... assets)

      Media assets of the Product Variant.

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

      Media assets of the Product Variant.

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

      Media assets of the Product Variant.

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

      public ProductVariantBuilder addAssets(Function<AssetBuilder,Asset> builder)

      Media assets of the Product Variant.

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

      public ProductVariantBuilder setAssets(Function<AssetBuilder,Asset> builder)

      Media assets of the Product Variant.

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

      Set if the Product Variant is tracked by Inventory. Can be used as an optimization to reduce calls to the Inventory service. May not contain the latest Inventory State (it is eventually consistent).

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

      Set if the Product Variant is tracked by Inventory. Can be used as an optimization to reduce calls to the Inventory service. May not contain the latest Inventory State (it is eventually consistent).

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

      public ProductVariantBuilder availability(@Nullable ProductVariantAvailability availability)

      Set if the Product Variant is tracked by Inventory. Can be used as an optimization to reduce calls to the Inventory service. May not contain the latest Inventory State (it is eventually consistent).

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

      public ProductVariantBuilder isMatchingVariant(@Nullable Boolean isMatchingVariant)

      true if the Product Variant matches the search query. Only available in response to a Product Projection Search request.

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

      Only available in response to a Product Projection Search request with Product price selection. Can be used to sort, filter, and facet.

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

      public ProductVariantBuilder withScopedPrice(Function<ScopedPriceBuilder,ScopedPrice> builder)

      Only available in response to a Product Projection Search request with Product price selection. Can be used to sort, filter, and facet.

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

      public ProductVariantBuilder scopedPrice(@Nullable ScopedPrice scopedPrice)

      Only available in response to a Product Projection Search request with Product price selection. Can be used to sort, filter, and facet.

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

      public ProductVariantBuilder scopedPriceDiscounted(@Nullable Boolean scopedPriceDiscounted)

      Only available in response to a Product Projection Search request with Product price selection.

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

      public Long getId()

      A unique, sequential identifier of the Product Variant within the Product.

      Returns:
      id
    • getSku

      @Nullable public String getSku()

      User-defined unique SKU of the Product Variant.

      Returns:
      sku
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the ProductVariant.

      This is different from Product key.

      Returns:
      key
    • getPrices

      @Nullable public List<Price> getPrices()

      The Embedded Prices of the Product Variant. Cannot contain two Prices of the same Price scope (with same currency, country, Customer Group, Channel, validFrom and validUntil).

      Returns:
      prices
    • getAttributes

      @Nullable public List<Attribute> getAttributes()

      Attributes of the Product Variant.

      Returns:
      attributes
    • getPrice

      @Nullable public Price getPrice()

      Only available when price selection is used. Cannot be used in a Query Predicate.

      Returns:
      price
    • getImages

      @Nullable public List<Image> getImages()

      Images of the Product Variant.

      Returns:
      images
    • getAssets

      @Nullable public List<Asset> getAssets()

      Media assets of the Product Variant.

      Returns:
      assets
    • getAvailability

      @Nullable public ProductVariantAvailability getAvailability()

      Set if the Product Variant is tracked by Inventory. Can be used as an optimization to reduce calls to the Inventory service. May not contain the latest Inventory State (it is eventually consistent).

      Returns:
      availability
    • getIsMatchingVariant

      @Nullable public Boolean getIsMatchingVariant()

      true if the Product Variant matches the search query. Only available in response to a Product Projection Search request.

      Returns:
      isMatchingVariant
    • getScopedPrice

      @Nullable public ScopedPrice getScopedPrice()

      Only available in response to a Product Projection Search request with Product price selection. Can be used to sort, filter, and facet.

      Returns:
      scopedPrice
    • getScopedPriceDiscounted

      @Nullable public Boolean getScopedPriceDiscounted()

      Only available in response to a Product Projection Search request with Product price selection.

      Returns:
      scopedPriceDiscounted
    • build

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

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

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

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