Class AttributeBuilder

java.lang.Object
com.commercetools.api.models.product.AttributeBuilder
All Implemented Interfaces:
Builder<Attribute>

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

     Attribute attribute = Attribute.builder()
             .name("{name}")
             .build()
 
  • Constructor Details

    • AttributeBuilder

      public AttributeBuilder()
  • Method Details

    • name

      public AttributeBuilder name(String name)

      Name of the Attribute.

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

      public AttributeBuilder value(Object value)

      The AttributeType determines the format of the Attribute value to be provided:

      • For Enum Type and Localized Enum Type, use the key of the Plain Enum Value or Localized Enum Value objects, or the complete objects as value.
      • For Localizable Text Type, use the LocalizedString object as value.
      • For Money Type Attributes, use the Money object as value.
      • For Set Type Attributes, use the entire set object as value.
      • For Nested Type Attributes, use the list of values of all Attributes of the nested Product as value.
      • For Reference Type Attributes, use the Reference object as value.
      Parameters:
      value - value to be set
      Returns:
      Builder
    • getName

      public String getName()

      Name of the Attribute.

      Returns:
      name
    • getValue

      public Object getValue()

      The AttributeType determines the format of the Attribute value to be provided:

      • For Enum Type and Localized Enum Type, use the key of the Plain Enum Value or Localized Enum Value objects, or the complete objects as value.
      • For Localizable Text Type, use the LocalizedString object as value.
      • For Money Type Attributes, use the Money object as value.
      • For Set Type Attributes, use the entire set object as value.
      • For Nested Type Attributes, use the list of values of all Attributes of the nested Product as value.
      • For Reference Type Attributes, use the Reference object as value.
      Returns:
      value
    • build

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

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

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

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