Class FieldDefinitionBuilder

java.lang.Object
com.commercetools.api.models.type.FieldDefinitionBuilder
All Implemented Interfaces:
Builder<FieldDefinition>

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

     FieldDefinition fieldDefinition = FieldDefinition.builder()
             .type(typeBuilder -> typeBuilder)
             .name("{name}")
             .label(labelBuilder -> labelBuilder)
             .required(true)
             .build()
 
  • Constructor Details

    • FieldDefinitionBuilder

      public FieldDefinitionBuilder()
  • Method Details

    • type

      public FieldDefinitionBuilder type(FieldType type)

      Data type of the Custom Field to define.

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

      Data type of the Custom Field to define.

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

      public FieldDefinitionBuilder name(String name)

      Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

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

      A human-readable label for the field.

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

      A human-readable label for the field.

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

      A human-readable label for the field.

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

      public FieldDefinitionBuilder required(Boolean required)

      Defines whether the field is required to have a value.

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

      public FieldDefinitionBuilder inputHint(@Nullable TypeTextInputHint inputHint)

      Defines the visual representation of the field in user interfaces like the Merchant Center. It is only relevant for string-based FieldTypes like CustomFieldStringType and CustomFieldLocalizedStringType.

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

      public FieldType getType()

      Data type of the Custom Field to define.

      Returns:
      type
    • getName

      public String getName()

      Name of the Custom Field to define. Must be unique for a given ResourceTypeId. In case there is a FieldDefinition with the same name in another Type, both FieldDefinitions must have the same type.

      Returns:
      name
    • getLabel

      public LocalizedString getLabel()

      A human-readable label for the field.

      Returns:
      label
    • getRequired

      public Boolean getRequired()

      Defines whether the field is required to have a value.

      Returns:
      required
    • getInputHint

      @Nullable public TypeTextInputHint getInputHint()

      Defines the visual representation of the field in user interfaces like the Merchant Center. It is only relevant for string-based FieldTypes like CustomFieldStringType and CustomFieldLocalizedStringType.

      Returns:
      inputHint
    • build

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

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

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

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