Class ImportFieldConfig

java.lang.Object
com.broadleafcommerce.dataimport.domain.ImportFieldConfig

public class ImportFieldConfig extends Object
Represents field configuration for imported field.

Within configuration we can specify:

  • Property name in a business object(e.g. name property in Product) propertyName
  • Is field required or not required
  • Field max length maxLength
  • Field validation ImportFieldValidator
Author:
Vitalii Voronkov (vvoronkov)
  • Constructor Details

    • ImportFieldConfig

      public ImportFieldConfig(@NonNull @NonNull String propertyName, boolean required)
    • ImportFieldConfig

      public ImportFieldConfig(@NonNull @NonNull String propertyName, boolean required, int maxLength)
  • Method Details

    • withValidator

      public ImportFieldConfig withValidator(ImportFieldValidator validator)
      Adds the given validator to getValidators().

      This method will additionally execute the given validator against getDefaultValue() if one is present.

      Parameters:
      validator - the validator to add to getValidators()
      Returns:
      this instance for further modification
      Throws:
      IllegalArgumentException - if getDefaultValue() is present and fails validation against validator
    • withDefaultValue

      public ImportFieldConfig withDefaultValue(String defaultValue)
      Sets a default value for this field.

      This method will additionally execute every current validator in getValidators() against the given defaultValue.

      Parameters:
      defaultValue - the default value to use for this field
      Returns:
      this instance for further modification
      Throws:
      IllegalArgumentException - if the given defaultValue fails validation against any of the getValidators()
    • getPropertyName

      public String getPropertyName()
      Property name in business object
    • isRequired

      public boolean isRequired()
      For many import scenarios, a field in an input line is either required or it is not and could be represented by a simple boolean value.
    • getMaxLength

      public int getMaxLength()
      Limits field max length
      See Also:
    • getValidators

      public List<ImportFieldValidator> getValidators()
      Validation for imported field
    • getDefaultValue

      public String getDefaultValue()
      Provides a default value for a field, if one is not provided by the input.