Class VariantBuilder

java.lang.Object
com.commercetools.api.models.variant.VariantBuilder
All Implemented Interfaces:
Builder<Variant>

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

     Variant variant = Variant.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .variantId(0.3)
             .product(productBuilder -> productBuilder)
             .published(true)
             .current(currentBuilder -> currentBuilder)
             .build()
 
  • Constructor Details

    • VariantBuilder

      public VariantBuilder()
  • Method Details

    • id

      public VariantBuilder id(String id)

      Unique identifier of the Variant.

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

      public VariantBuilder version(Long version)

      Current version of the Variant.

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

      public VariantBuilder createdAt(ZonedDateTime createdAt)

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

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

      public VariantBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the Variant was last updated.

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

      IDs and references that last modified the Variant.

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

      public VariantBuilder withLastModifiedBy(Function<LastModifiedByBuilder,LastModifiedBy> builder)

      IDs and references that last modified the Variant.

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

      public VariantBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the Variant.

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

      IDs and references that created the Variant.

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

      public VariantBuilder withCreatedBy(Function<CreatedByBuilder,CreatedBy> builder)

      IDs and references that created the Variant.

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

      public VariantBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the Variant.

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

      public VariantBuilder key(@Nullable String key)

      User-defined unique identifier of the Variant. This is different from Product key.

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

      public VariantBuilder variantId(Integer variantId)

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

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

      Reference to the parent Product the Variant belongs to.

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

      Reference to the parent Product the Variant belongs to.

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

      public VariantBuilder product(ProductReference product)

      Reference to the parent Product the Variant belongs to.

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

      public VariantBuilder published(Boolean published)

      true if the Variant is published, false if it is unpublished.

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

      The current data of the Variant.

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

      public VariantBuilder withCurrent(Function<VariantDataBuilder,VariantData> builder)

      The current data of the Variant.

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

      public VariantBuilder current(VariantData current)

      The current data of the Variant.

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

      The staged data of the Variant. Only present if there are staged changes that differ from the current data.

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

      public VariantBuilder withStaged(Function<VariantDataBuilder,VariantData> builder)

      The staged data of the Variant. Only present if there are staged changes that differ from the current data.

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

      public VariantBuilder staged(@Nullable VariantData staged)

      The staged data of the Variant. Only present if there are staged changes that differ from the current data.

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

      public String getId()

      Unique identifier of the Variant.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the Variant.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

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

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

      Date and time (UTC) the Variant was last updated.

      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the Variant.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the Variant.

      Returns:
      createdBy
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the Variant. This is different from Product key.

      Returns:
      key
    • getVariantId

      public Integer getVariantId()

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

      Returns:
      variantId
    • getProduct

      public ProductReference getProduct()

      Reference to the parent Product the Variant belongs to.

      Returns:
      product
    • getPublished

      public Boolean getPublished()

      true if the Variant is published, false if it is unpublished.

      Returns:
      published
    • getCurrent

      public VariantData getCurrent()

      The current data of the Variant.

      Returns:
      current
    • getStaged

      @Nullable public VariantData getStaged()

      The staged data of the Variant. Only present if there are staged changes that differ from the current data.

      Returns:
      staged
    • build

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

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

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

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