Class RequireSubStr

java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.RequireSubStr
All Implemented Interfaces:
CellProcessor, StringCellProcessor

public class RequireSubStr extends CellProcessorAdaptor implements StringCellProcessor
Converts the input to a String and ensures that the input contains at least one of the specified substrings.
Since:
1.10
  • Field Details

    • requiredSubStrings

      private final List<String> requiredSubStrings
  • Constructor Details

    • RequireSubStr

      public RequireSubStr(String... requiredSubStrings)
      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 null
      IllegalArgumentException - if requiredSubStrings is empty
    • RequireSubStr

      public 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.
      Parameters:
      requiredSubStrings - the List of required substrings
      next - the next processor in the chain
      Throws:
      NullPointerException - if requiredSubStrings, one of its elements or next is null
      IllegalArgumentException - if requiredSubStrings is empty
    • RequireSubStr

      public 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.
      Parameters:
      requiredSubString - the required substring
      next - the next processor in the chain
      Throws:
      NullPointerException - if requiredSubString or next is null
    • RequireSubStr

      public 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.
      Parameters:
      requiredSubStrings - the List of required substrings
      next - the next processor in the chain
      Throws:
      NullPointerException - if requiredSubStrings, one of its elements or next is null
      IllegalArgumentException - if requiredSubStrings is empty
  • Method Details

    • checkPreconditions

      private static void checkPreconditions(String... requiredSubStrings)
      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 null
      IllegalArgumentException - if requiredSubStrings is empty
    • checkPreconditions

      private static void checkPreconditions(List<String> requiredSubStrings)
      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 null
      IllegalArgumentException - if requiredSubStrings is empty
    • checkAndAddRequiredSubStrings

      private void checkAndAddRequiredSubStrings(List<String> requiredSubStrings)
      Adds each required substring, checking that it's not null.
      Parameters:
      requiredSubStrings - the required substrings
      Throws:
      NullPointerException - if a required substring is null
    • checkAndAddRequiredSubStrings

      private void checkAndAddRequiredSubStrings(String... requiredSubStrings)
      Adds each required substring, checking that it's not null.
      Parameters:
      requiredSubStrings - the required substrings
      Throws:
      NullPointerException - if a required substring is null
    • execute

      public Object execute(Object value, CsvContext context)
      This method is invoked by the framework when the processor needs to process data or check constraints.
      Specified by:
      execute in interface CellProcessor
      Parameters:
      value - the value to be processed
      context - the CSV context
      Returns:
      the result of cell processor execution
      Throws:
      SuperCsvCellProcessorException - if value is null
      SuperCsvConstraintViolationException - if value doesn't contain any of the required substrings