return new RequireSubStr(requiredSubStrings);
/** * Adds each required substring, checking that it's not null. * * @param requiredSubStrings * the required substrings * @throws NullPointerException * if a required substring is null */ private void checkAndAddRequiredSubStrings(final String... requiredSubStrings) { checkAndAddRequiredSubStrings(Arrays.asList(requiredSubStrings)); }
/** * Converts the input to a String and ensures that the input contains at least one of the specified substrings. * * @param requiredSubStrings * the required substrings * @throws NullPointerException * if requiredSubStrings or one of its elements is null * @throws IllegalArgumentException * if requiredSubStrings is empty */ public RequireSubStr(final String... requiredSubStrings) { super(); checkPreconditions(requiredSubStrings); checkAndAddRequiredSubStrings(requiredSubStrings); }
/** * {@inheritDoc} * * @throws SuperCsvCellProcessorException * if value is null * @throws SuperCsvConstraintViolationException * if value doesn't contain any of the required substrings */ public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String stringValue = value.toString(); for( final String required : requiredSubStrings ) { if( stringValue.contains(required) ) { return next.execute(value, context); // just need to match a single substring } } throw new SuperCsvConstraintViolationException(String.format("'%s' does not contain any of the required substrings", value), context, this); } }
/** * Converts the input to a String, ensures that the input contains the specified substring, then calls the next * processor in the chain. * * @param requiredSubString * the required substring * @param next * the next processor in the chain * @throws NullPointerException * if requiredSubString or next is null */ public RequireSubStr(final String requiredSubString, final CellProcessor next) { super(next); checkPreconditions(requiredSubString); checkAndAddRequiredSubStrings(requiredSubString); }
return new RequireSubStr(requiredSubStrings);
/** * 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. * * @param requiredSubStrings * the List of required substrings * @param next * the next processor in the chain * @throws NullPointerException * if requiredSubStrings, one of its elements or next is null * @throws IllegalArgumentException * if requiredSubStrings is empty */ public RequireSubStr(final List<String> requiredSubStrings, final CellProcessor next) { super(next); checkPreconditions(requiredSubStrings); checkAndAddRequiredSubStrings(requiredSubStrings); }
/** * 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. * * @param requiredSubStrings * the List of required substrings * @param next * the next processor in the chain * @throws NullPointerException * if requiredSubStrings, one of its elements or next is null * @throws IllegalArgumentException * if requiredSubStrings is empty */ public RequireSubStr(final String[] requiredSubStrings, final CellProcessor next) { super(next); checkPreconditions(requiredSubStrings); checkAndAddRequiredSubStrings(requiredSubStrings); }