Interface VariantProjection


public interface VariantProjection

A lightweight, read-only projection of a single Variant with embedded Product data. Variant Projections are automatically created and updated when Variants or their parent Products change.


Example to create an instance using the builder pattern

     VariantProjection variantProjection = VariantProjection.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .staged(true)
             .variantId(0.3)
             .product(productBuilder -> productBuilder)
             .name(nameBuilder -> nameBuilder)
             .slug(slugBuilder -> slugBuilder)
             .plusImages(imagesBuilder -> imagesBuilder)
             .plusAssets(assetsBuilder -> assetsBuilder)
             .plusAttributes(attributesBuilder -> attributesBuilder)
             .default(true)
             .build()
 
  • Method Details

    • getId

      @NotNull @NotNull String getId()

      Unique identifier of the Variant within its parent Product.

      Returns:
      id
    • getVersion

      @NotNull @NotNull Long getVersion()

      Current version of the Variant Projection.

      Returns:
      version
    • getCreatedAt

      @NotNull @NotNull ZonedDateTime getCreatedAt()

      Date and time (UTC) the Variant Projection was initially created.

      Returns:
      createdAt
    • getStaged

      @NotNull @NotNull Boolean getStaged()

      true for the staged (draft) projection, false for the current (published) projection.

      Returns:
      staged
    • getVariantId

      @NotNull @NotNull Integer getVariantId()

      The id of the Variant.

      Returns:
      variantId
    • getProduct

      @NotNull @Valid @NotNull @Valid ProductReference getProduct()

      Reference to the parent Product.

      Returns:
      product
    • getName

      @NotNull @Valid @NotNull @Valid LocalizedString getName()

      Name of the parent Product.

      Returns:
      name
    • getSlug

      @NotNull @Valid @NotNull @Valid LocalizedString getSlug()

      Slug of the parent Product.

      Returns:
      slug
    • getDescription

      @Valid @Valid LocalizedString getDescription()

      Description of the parent Product.

      Returns:
      description
    • getKey

      String getKey()

      User-defined unique identifier of the Variant.

      Returns:
      key
    • getSku

      String getSku()

      SKU of the Variant.

      Returns:
      sku
    • getImages

      @NotNull @Valid @NotNull @Valid List<Image> getImages()

      Images of the Variant.

      Returns:
      images
    • getAssets

      @NotNull @Valid @NotNull @Valid List<Asset> getAssets()

      Assets of the Variant.

      Returns:
      assets
    • getAttributes

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

      Attributes of the Variant, including product-level Attributes merged at projection time.

      Returns:
      attributes
    • getPrice

      @Valid @Valid Price getPrice()

      The selected price based on the price selection query parameters. Only present when price selection parameters are provided.

      Returns:
      price
    • getDefault

      @NotNull @NotNull Boolean getDefault()

      true if this Variant is the default Variant of its Product (see Product.defaultVariant). false otherwise.

      Returns:
      default
    • setId

      void setId(String id)

      Unique identifier of the Variant within its parent Product.

      Parameters:
      id - value to be set
    • setVersion

      void setVersion(Long version)

      Current version of the Variant Projection.

      Parameters:
      version - value to be set
    • setCreatedAt

      void setCreatedAt(ZonedDateTime createdAt)

      Date and time (UTC) the Variant Projection was initially created.

      Parameters:
      createdAt - value to be set
    • setStaged

      void setStaged(Boolean staged)

      true for the staged (draft) projection, false for the current (published) projection.

      Parameters:
      staged - value to be set
    • setVariantId

      void setVariantId(Integer variantId)

      The id of the Variant.

      Parameters:
      variantId - value to be set
    • setProduct

      void setProduct(ProductReference product)

      Reference to the parent Product.

      Parameters:
      product - value to be set
    • setName

      void setName(LocalizedString name)

      Name of the parent Product.

      Parameters:
      name - value to be set
    • setSlug

      void setSlug(LocalizedString slug)

      Slug of the parent Product.

      Parameters:
      slug - value to be set
    • setDescription

      void setDescription(LocalizedString description)

      Description of the parent Product.

      Parameters:
      description - value to be set
    • setKey

      void setKey(String key)

      User-defined unique identifier of the Variant.

      Parameters:
      key - value to be set
    • setSku

      void setSku(String sku)

      SKU of the Variant.

      Parameters:
      sku - value to be set
    • setImages

      void setImages(Image... images)

      Images of the Variant.

      Parameters:
      images - values to be set
    • setImages

      void setImages(List<Image> images)

      Images of the Variant.

      Parameters:
      images - values to be set
    • setAssets

      void setAssets(Asset... assets)

      Assets of the Variant.

      Parameters:
      assets - values to be set
    • setAssets

      void setAssets(List<Asset> assets)

      Assets of the Variant.

      Parameters:
      assets - values to be set
    • setAttributes

      void setAttributes(Attribute... attributes)

      Attributes of the Variant, including product-level Attributes merged at projection time.

      Parameters:
      attributes - values to be set
    • setAttributes

      void setAttributes(List<Attribute> attributes)

      Attributes of the Variant, including product-level Attributes merged at projection time.

      Parameters:
      attributes - values to be set
    • setPrice

      void setPrice(Price price)

      The selected price based on the price selection query parameters. Only present when price selection parameters are provided.

      Parameters:
      price - value to be set
    • setDefault

      void setDefault(Boolean _default)

      true if this Variant is the default Variant of its Product (see Product.defaultVariant). false otherwise.

      Parameters:
      _default - value to be set
    • of

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

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

      VariantProjection copyDeep()
    • deepCopy

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

      static VariantProjectionBuilder builder()
      builder factory method for VariantProjection
      Returns:
      builder
    • builder

      static VariantProjectionBuilder builder(VariantProjection template)
      create builder for VariantProjection instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withVariantProjection

      default <T> T withVariantProjection(Function<VariantProjection,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<VariantProjection> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference