Class ImportFieldConfig
java.lang.Object
com.broadleafcommerce.dataimport.domain.ImportFieldConfig
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 Summary
ConstructorsConstructorDescriptionImportFieldConfig(@NonNull String propertyName, boolean required) ImportFieldConfig(@NonNull String propertyName, boolean required, int maxLength) -
Method Summary
Modifier and TypeMethodDescriptionProvides a default value for a field, if one is not provided by the input.intLimits field max lengthProperty name in business objectValidation for imported fieldbooleanFor 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.withDefaultValue(String defaultValue) Sets a default value for this field.withValidator(ImportFieldValidator validator) Adds the givenvalidatortogetValidators().
-
Constructor Details
-
ImportFieldConfig
-
ImportFieldConfig
-
-
Method Details
-
withValidator
Adds the givenvalidatortogetValidators().This method will additionally execute the given
validatoragainstgetDefaultValue()if one is present.- Parameters:
validator- the validator to add togetValidators()- Returns:
- this instance for further modification
- Throws:
IllegalArgumentException- ifgetDefaultValue()is present and fails validation againstvalidator
-
withDefaultValue
Sets a default value for this field.This method will additionally execute every current validator in
getValidators()against the givendefaultValue.- Parameters:
defaultValue- the default value to use for this field- Returns:
- this instance for further modification
- Throws:
IllegalArgumentException- if the givendefaultValuefails validation against any of thegetValidators()
-
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
Validation for imported field -
getDefaultValue
Provides a default value for a field, if one is not provided by the input.
-