Class RequireSubStr
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.RequireSubStr
- All Implemented Interfaces:
CellProcessor, StringCellProcessor
Converts the input to a String and ensures that the input contains at least one of the specified substrings.
- Since:
- 1.10
-
Field Summary
FieldsFields inherited from class CellProcessorAdaptor
next -
Constructor Summary
ConstructorsConstructorDescriptionRequireSubStr(String... requiredSubStrings) Converts the input to a String and ensures that the input contains at least one of the specified substrings.RequireSubStr(String[] requiredSubStrings, CellProcessor next) Converts the input to a String, ensures that the input contains at least one of the specified substrings, then calls the next processor in the chain.RequireSubStr(String requiredSubString, CellProcessor next) Converts the input to a String, ensures that the input contains the specified substring, then calls the next processor in the chain.RequireSubStr(List<String> requiredSubStrings, CellProcessor next) Converts the input to a String, ensures that the input contains at least one of the specified substrings, then calls the next processor in the chain. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckAndAddRequiredSubStrings(String... requiredSubStrings) Adds each required substring, checking that it's not null.private voidcheckAndAddRequiredSubStrings(List<String> requiredSubStrings) Adds each required substring, checking that it's not null.private static voidcheckPreconditions(String... requiredSubStrings) Checks the preconditions for creating a new RequireSubStr processor with an array of Strings.private static voidcheckPreconditions(List<String> requiredSubStrings) Checks the preconditions for creating a new RequireSubStr processor with a List of Strings.execute(Object value, CsvContext context) This method is invoked by the framework when the processor needs to process data or check constraints.Methods inherited from class CellProcessorAdaptor
toString, validateInputNotNull
-
Field Details
-
requiredSubStrings
-
-
Constructor Details
-
RequireSubStr
Converts the input to a String and ensures that the input contains at least one of the specified substrings.- Parameters:
requiredSubStrings- the required substrings- Throws:
NullPointerException- if requiredSubStrings or one of its elements is nullIllegalArgumentException- if requiredSubStrings is empty
-
RequireSubStr
Converts the input to a String, ensures that the input contains at least one of the specified substrings, then calls the next processor in the chain.- Parameters:
requiredSubStrings- the List of required substringsnext- the next processor in the chain- Throws:
NullPointerException- if requiredSubStrings, one of its elements or next is nullIllegalArgumentException- if requiredSubStrings is empty
-
RequireSubStr
Converts the input to a String, ensures that the input contains the specified substring, then calls the next processor in the chain.- Parameters:
requiredSubString- the required substringnext- the next processor in the chain- Throws:
NullPointerException- if requiredSubString or next is null
-
RequireSubStr
Converts the input to a String, ensures that the input contains at least one of the specified substrings, then calls the next processor in the chain.- Parameters:
requiredSubStrings- the List of required substringsnext- the next processor in the chain- Throws:
NullPointerException- if requiredSubStrings, one of its elements or next is nullIllegalArgumentException- if requiredSubStrings is empty
-
-
Method Details
-
checkPreconditions
Checks the preconditions for creating a new RequireSubStr processor with an array of Strings.- Parameters:
requiredSubStrings- the required substrings- Throws:
NullPointerException- if requiredSubStrings or one of its elements is nullIllegalArgumentException- if requiredSubStrings is empty
-
checkPreconditions
Checks the preconditions for creating a new RequireSubStr processor with a List of Strings.- Parameters:
requiredSubStrings- the required substrings- Throws:
NullPointerException- if requiredSubStrings or one of its elements is nullIllegalArgumentException- if requiredSubStrings is empty
-
checkAndAddRequiredSubStrings
Adds each required substring, checking that it's not null.- Parameters:
requiredSubStrings- the required substrings- Throws:
NullPointerException- if a required substring is null
-
checkAndAddRequiredSubStrings
Adds each required substring, checking that it's not null.- Parameters:
requiredSubStrings- the required substrings- Throws:
NullPointerException- if a required substring is null
-
execute
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
executein interfaceCellProcessor- Parameters:
value- the value to be processedcontext- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException- if value is nullSuperCsvConstraintViolationException- if value doesn't contain any of the required substrings
-