Class FieldDefinitionBuilder

java.lang.Object
com.commercetools.importapi.models.types.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 that you want to define. The name must be unique for a given ResourceTypeId. If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type. This value can't be changed after you import the 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. This value cannot be changed after the Type is imported.

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

      public FieldDefinitionBuilder inputHint(@Nullable TypeTextInputHint inputHint)

      Provides a visual representation type for this field. It is only relevant for string-based field types 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 that you want to define. The name must be unique for a given ResourceTypeId. If a FieldDefinition with the same name is defined in another Type for the same ResourceTypeId, then both FieldDefinitions must have the same type. This value can't be changed after you import the 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. This value cannot be changed after the Type is imported.

      Returns:
      required
    • getInputHint

      @Nullable public TypeTextInputHint getInputHint()

      Provides a visual representation type for this field. It is only relevant for string-based field types 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