public class ConvertEmptyOrBlankStringsToDefault extends Object implements StringProcessor
A sample of this can be found in the unit test ProcessorTestBean and is annotated as follows.
@PreAssignmentProcessor(processor = ConvertEmptyOrBlankStringsToDefault.class, paramString = "-1")
@CsvBindByName(column = "id")
private int beanId;
| Constructor and Description |
|---|
ConvertEmptyOrBlankStringsToDefault()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
String |
processString(String value)
Method that contains the code that will transform a string into the
value that will be validated and converted into the bean field.
|
void |
setParameterString(String value)
This allows the validator extending
StringProcessor to be used
by multiple fields by allowing you to pass in data for the processor to
be used. |
public ConvertEmptyOrBlankStringsToDefault()
public String processString(String value)
StringProcessorprocessString in interface StringProcessorvalue - String to be processedStringpublic void setParameterString(String value)
StringProcessorStringProcessor to be used
by multiple fields by allowing you to pass in data for the processor to
be used.
The data could be a default value or whatever the custom processor requires to convert the data.
If the processor needs multiple parameters, then you will need to combine them into a single string using some sort of delimiter, say a comma, and parse them out using some library that allows you to parse such strings 😁.
If the processor does not need a value then just create an empty method like the ConvertEmptyOrBlankStringsToNull processor used by the BeanFieldProcessorTest.
setParameterString in interface StringProcessorvalue - Information used by the processor to process the stringCopyright © 2005–2025. All rights reserved.