Class AttributeDefinitionBuilder

java.lang.Object
com.commercetools.history.models.common.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)
             .inputTip(inputTipBuilder -> inputTipBuilder)
             .inputHint(TextInputHint.SINGLE_LINE)
             .isSearchable(true)
             .build()
 
  • Constructor Details

    • AttributeDefinitionBuilder

      public AttributeDefinitionBuilder()
  • Method Details

    • type

      set the value to the type using the builder function
      Parameters:
      builder - function to build the type value
      Returns:
      Builder
    • withType

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

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

      public AttributeDefinitionBuilder name(String name)

      The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). When using the same name for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an enum or lenum type and sets thereof.

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

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

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

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

      public AttributeDefinitionBuilder isRequired(Boolean isRequired)

      Whether the attribute is required to have a value.

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

      public AttributeDefinitionBuilder attributeConstraint(AttributeConstraintEnum attributeConstraint)
      set the value to the attributeConstraint
      Parameters:
      attributeConstraint - value to be set
      Returns:
      Builder
    • inputTip

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

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

      public AttributeDefinitionBuilder inputTip(LocalizedString inputTip)
      set the value to the inputTip
      Parameters:
      inputTip - value to be set
      Returns:
      Builder
    • inputHint

      public AttributeDefinitionBuilder inputHint(TextInputHint inputHint)
      set the value to the inputHint
      Parameters:
      inputHint - value to be set
      Returns:
      Builder
    • isSearchable

      public AttributeDefinitionBuilder isSearchable(Boolean isSearchable)

      Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is restricted to 10922 characters. 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()
      value of type}
      Returns:
      type
    • getName

      public String getName()

      The unique name of the attribute used in the API. The name must be between two and 256 characters long and can contain the ASCII letters A to Z in lowercase or uppercase, digits, underscores (_) and the hyphen-minus (-). When using the same name for an attribute in two or more product types all fields of the AttributeDefinition of this attribute need to be the same across the product types, otherwise an AttributeDefinitionAlreadyExists error code will be returned. An exception to this are the values of an enum or lenum type and sets thereof.

      Returns:
      name
    • getLabel

      public LocalizedString getLabel()
      value of label}
      Returns:
      label
    • getIsRequired

      public Boolean getIsRequired()

      Whether the attribute is required to have a value.

      Returns:
      isRequired
    • getAttributeConstraint

      public AttributeConstraintEnum getAttributeConstraint()
      value of attributeConstraint}
      Returns:
      attributeConstraint
    • getInputTip

      public LocalizedString getInputTip()
      value of inputTip}
      Returns:
      inputTip
    • getInputHint

      public TextInputHint getInputHint()
      value of inputHint}
      Returns:
      inputHint
    • getIsSearchable

      public Boolean getIsSearchable()

      Whether the attribute's values should generally be enabled in product search. This determines whether the value is stored in products for matching terms in the context of full-text search queries and can be used in facets & filters as part of product search queries. The exact features that are enabled/disabled with this flag depend on the concrete attribute type and are described there. The max size of a searchable field is restricted to 10922 characters. 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