Class AttributeDefinitionBuilder

java.lang.Object
com.commercetools.api.models.product_type.AttributeDefinitionBuilder
All Implemented Interfaces:
Builder<AttributeDefinition>

public class AttributeDefinitionBuilder extends Object implements Builder<AttributeDefinition>
AttributeDefinitionBuilder
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()
 
  • Constructor Details

    • AttributeDefinitionBuilder

      public AttributeDefinitionBuilder()
  • Method Details

    • type

      Describes the Type of the Attribute.

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

      Describes the Type of the Attribute.

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

      public AttributeDefinitionBuilder name(String name)

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

      Parameters:
      name - value to be set
      Returns:
      Builder
    • label

      Human-readable label for the Attribute.

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

      Human-readable label for the Attribute.

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

      Human-readable label for the Attribute.

      Parameters:
      label - value to be set
      Returns:
      Builder
    • isRequired

      public AttributeDefinitionBuilder isRequired(Boolean isRequired)

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

      Parameters:
      isRequired - value to be set
      Returns:
      Builder
    • attributeConstraint

      public AttributeDefinitionBuilder attributeConstraint(AttributeConstraintEnum attributeConstraint)

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

      Parameters:
      attributeConstraint - value to be set
      Returns:
      Builder
    • inputTip

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

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

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

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

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

      Parameters:
      inputTip - value to be set
      Returns:
      Builder
    • inputHint

      public AttributeDefinitionBuilder inputHint(TextInputHint inputHint)

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

      Parameters:
      inputHint - value to be set
      Returns:
      Builder
    • isSearchable

      public AttributeDefinitionBuilder isSearchable(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
      Returns:
      Builder
    • getType

      public AttributeType getType()

      Describes the Type of the Attribute.

      Returns:
      type
    • getName

      public String getName()

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

      Returns:
      name
    • getLabel

      public LocalizedString getLabel()

      Human-readable label for the Attribute.

      Returns:
      label
    • getIsRequired

      public Boolean getIsRequired()

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

      Returns:
      isRequired
    • getAttributeConstraint

      public AttributeConstraintEnum getAttributeConstraint()

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

      Returns:
      attributeConstraint
    • getInputTip

      @Nullable public LocalizedString getInputTip()

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

      Returns:
      inputTip
    • getInputHint

      public TextInputHint getInputHint()

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

      Returns:
      inputHint
    • getIsSearchable

      public 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
    • build

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

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

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

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