Interface AttributeDefinition


public interface AttributeDefinition

Describes a Product Attribute and allows you to define meta-information associated with the Attribute (like whether it should be searchable, or its constraints).


Example to create an instance using the builder pattern

     AttributeDefinition attributeDefinition = AttributeDefinition.builder()
             .type(typeBuilder -> typeBuilder)
             .name("{name}")
             .label(labelBuilder -> labelBuilder)
             .isRequired(true)
             .attributeConstraint(AttributeConstraintEnum.NONE)
             .inputHint(TextInputHint.SINGLE_LINE)
             .isSearchable(true)
             .build()
 
  • Method Details

    • getType

      @NotNull @Valid @NotNull @Valid AttributeType getType()

      Describes the Type of the Attribute.

      Returns:
      type
    • getName

      @NotNull @NotNull String getName()

      User-defined name of the Attribute that is unique within the Project.

      Returns:
      name
    • getLabel

      @NotNull @Valid @NotNull @Valid LocalizedString getLabel()

      Human-readable label for the Attribute.

      Returns:
      label
    • getIsRequired

      @NotNull @NotNull Boolean getIsRequired()

      If true, the Attribute must have a value on a ProductVariant.

      Returns:
      isRequired
    • getAttributeConstraint

      @NotNull @NotNull AttributeConstraintEnum getAttributeConstraint()

      Specifies how Attributes are validated across all variants of a Product.

      Returns:
      attributeConstraint
    • getInputTip

      @Valid @Valid LocalizedString getInputTip()

      Provides additional Attribute information to aid content managers configure Product details.

      Returns:
      inputTip
    • getInputHint

      @NotNull @NotNull TextInputHint getInputHint()

      Provides a visual representation directive for values of this Attribute (only relevant for AttributeTextType and AttributeLocalizableTextType).

      Returns:
      inputHint
    • getIsSearchable

      @NotNull @NotNull Boolean getIsSearchable()

      If true, the Attribute's values are available for the Product Projections Search API for use in full-text search queries, filters, and facets.

      Which exact features are available with this flag depends on the specific AttributeType. The maximum size of a searchable field is restricted by the Field content size limit. This constraint is enforced at both Product creation and Product update. If the length of the input exceeds the maximum size, an InvalidField error is returned.

      Returns:
      isSearchable
    • setType

      void setType(AttributeType type)

      Describes the Type of the Attribute.

      Parameters:
      type - value to be set
    • setName

      void setName(String name)

      User-defined name of the Attribute that is unique within the Project.

      Parameters:
      name - value to be set
    • setLabel

      void setLabel(LocalizedString label)

      Human-readable label for the Attribute.

      Parameters:
      label - value to be set
    • setIsRequired

      void setIsRequired(Boolean isRequired)

      If true, the Attribute must have a value on a ProductVariant.

      Parameters:
      isRequired - value to be set
    • setAttributeConstraint

      void setAttributeConstraint(AttributeConstraintEnum attributeConstraint)

      Specifies how Attributes are validated across all variants of a Product.

      Parameters:
      attributeConstraint - value to be set
    • setInputTip

      void setInputTip(LocalizedString inputTip)

      Provides additional Attribute information to aid content managers configure Product details.

      Parameters:
      inputTip - value to be set
    • setInputHint

      void setInputHint(TextInputHint inputHint)

      Provides a visual representation directive for values of this Attribute (only relevant for AttributeTextType and AttributeLocalizableTextType).

      Parameters:
      inputHint - value to be set
    • setIsSearchable

      void setIsSearchable(Boolean isSearchable)

      If true, the Attribute's values are available for the Product Projections Search API for use in full-text search queries, filters, and facets.

      Which exact features are available with this flag depends on the specific AttributeType. The maximum size of a searchable field is restricted by the Field content size limit. This constraint is enforced at both Product creation and Product update. If the length of the input exceeds the maximum size, an InvalidField error is returned.

      Parameters:
      isSearchable - value to be set
    • of

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

      factory method to create a shallow copy AttributeDefinition
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      factory method to create a deep copy of AttributeDefinition
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static AttributeDefinitionBuilder builder()
      builder factory method for AttributeDefinition
      Returns:
      builder
    • builder

      create builder for AttributeDefinition instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withAttributeDefinition

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

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