Interface VariantAttributes


public interface VariantAttributes

A lightweight representation of a Product's Variants with only the requested Attributes and minimal availability data. Designed for building attribute selectors on product detail pages (PDPs).


Example to create an instance using the builder pattern

     VariantAttributes variantAttributes = VariantAttributes.builder()
             .productId("{productId}")
             .plusAttributes(attributesBuilder -> attributesBuilder)
             .plusVariants(variantsBuilder -> variantsBuilder)
             .build()
 
  • Method Details

    • getProductId

      @NotNull @NotNull String getProductId()

      Unique identifier of the Product.

      Returns:
      productId
    • getProductKey

      String getProductKey()

      User-defined unique identifier of the Product.

      Returns:
      productKey
    • getAttributes

      @NotNull @Valid @NotNull @Valid List<VariantAttributesAttributeMetadata> getAttributes()

      Metadata for the requested Attributes, derived from the ProductType. Attributes not found in the ProductType are silently omitted.

      Returns:
      attributes
    • getVariants

      @NotNull @Valid @NotNull @Valid List<VariantAttributesVariant> getVariants()

      All Variants of the Product with their requested Attributes and availability.

      Returns:
      variants
    • setProductId

      void setProductId(String productId)

      Unique identifier of the Product.

      Parameters:
      productId - value to be set
    • setProductKey

      void setProductKey(String productKey)

      User-defined unique identifier of the Product.

      Parameters:
      productKey - value to be set
    • setAttributes

      void setAttributes(VariantAttributesAttributeMetadata... attributes)

      Metadata for the requested Attributes, derived from the ProductType. Attributes not found in the ProductType are silently omitted.

      Parameters:
      attributes - values to be set
    • setAttributes

      void setAttributes(List<VariantAttributesAttributeMetadata> attributes)

      Metadata for the requested Attributes, derived from the ProductType. Attributes not found in the ProductType are silently omitted.

      Parameters:
      attributes - values to be set
    • setVariants

      void setVariants(VariantAttributesVariant... variants)

      All Variants of the Product with their requested Attributes and availability.

      Parameters:
      variants - values to be set
    • setVariants

      void setVariants(List<VariantAttributesVariant> variants)

      All Variants of the Product with their requested Attributes and availability.

      Parameters:
      variants - values to be set
    • of

      static VariantAttributes of()
      factory method
      Returns:
      instance of VariantAttributes
    • of

      static VariantAttributes of(VariantAttributes template)
      factory method to create a shallow copy VariantAttributes
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • copyDeep

      VariantAttributes copyDeep()
    • deepCopy

      @Nullable static VariantAttributes deepCopy(@Nullable VariantAttributes template)
      factory method to create a deep copy of VariantAttributes
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static VariantAttributesBuilder builder()
      builder factory method for VariantAttributes
      Returns:
      builder
    • builder

      static VariantAttributesBuilder builder(VariantAttributes template)
      create builder for VariantAttributes instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withVariantAttributes

      default <T> T withVariantAttributes(Function<VariantAttributes,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static tools.jackson.core.type.TypeReference<VariantAttributes> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference