/** * Constructs a new <tt>StrMinMax</tt> processor, which ensures that the input data has a string length between the * supplied min and max values (both inclusive). * * @param min * the minimum String length * @param max * the maximum String length * @throws IllegalArgumentException * if {@code max < min}, or {@code min is < 0} */ public StrMinMax(final long min, final long max) { super(); checkPreconditions(min, max); this.min = min; this.max = max; }
/** * {@inheritDoc} * * @throws SuperCsvCellProcessorException * if value is null * @throws SuperCsvConstraintViolationException * if {@code length < min} or {@code length > max} */ public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); final String stringValue = value.toString(); final int length = stringValue.length(); if( length < min || length > max ) { throw new SuperCsvConstraintViolationException(String.format( "the length (%d) of value '%s' does not lie between the min (%d) and max (%d) values (inclusive)", length, stringValue, min, max), context, this); } return next.execute(stringValue, context); } }
/** * Constructs a new <tt>StrMinMax</tt> processor, which ensures that the input data has a string length between the * supplied min and max values (both inclusive), then calls the next processor in the chain. * * @param min * the minimum String length * @param max * the maximum String length * @param next * the next processor in the chain * @throws NullPointerException * if next is null * @throws IllegalArgumentException * if {@code max < min}, or {@code min is < 0} */ public StrMinMax(final long min, final long max, final CellProcessor next) { super(next); checkPreconditions(min, max); this.min = min; this.max = max; }
return new StrMinMax(Long.parseLong(splits[0]), Long.parseLong(splits[1]));
Long min = minLength == null ? 0L : minLength; Long max = maxLength == null ? LMinMax.MAX_LONG : maxLength; cellProcessor = new StrMinMax(min, max);
Long min = minLength == null ? 0L : minLength; Long max = maxLength == null ? LMinMax.MAX_LONG : maxLength; cellProcessor = new StrMinMax(min, max);
new SuppressException(new StrMinMax(0, 4)), new SuppressException(new NotNull()) };
return new StrMinMax(Long.parseLong(splits[0]), Long.parseLong(splits[1]));