hashcodes[i] = Integer.parseInt(hashs[i]); return new RequireHashCode(hashcodes);
/** * Constructs a new <tt>RequireHashCode</tt> processor, which converts the input to a String, ensures that the * input's hash function matches any of a given set of hashcodes, then calls the next processor in the chain. * * @param requiredHashcodes * one or more hashcodes * @param next * the next processor in the chain * @throws NullPointerException * if requiredHashcodes or next is null * @throws IllegalArgumentException * if requiredHashcodes is empty */ public RequireHashCode(final int[] requiredHashcodes, final CellProcessor next) { super(next); checkPreconditions(requiredHashcodes); for( final int hash : requiredHashcodes ) { this.requiredHashCodes.add(hash); } }
/** * {@inheritDoc} * * @throws SuperCsvCellProcessorException * if value is null * @throws SuperCsvConstraintViolationException * if value isn't one of the required hash codes */ public Object execute(final Object value, final CsvContext context) { validateInputNotNull(value, context); int hash = value.hashCode(); if( !requiredHashCodes.contains(hash) ) { throw new SuperCsvConstraintViolationException(String.format( "the hashcode of %d for value '%s' does not match any of the required hashcodes", hash, value), context, this); } return next.execute(value, context); }
/** * Constructs a new <tt>RequireHashCode</tt> processor, which converts the input to a String, and ensures that the * input's hash function matches any of a given set of hashcodes. * * @param requiredHashcodes * one or more hashcodes * @throws NullPointerException * if requiredHashcodes is null * @throws IllegalArgumentException * if requiredHashcodes is empty */ public RequireHashCode(final int... requiredHashcodes) { super(); checkPreconditions(requiredHashcodes); for( final int hash : requiredHashcodes ) { this.requiredHashCodes.add(hash); } }
hashcodes[i] = Integer.parseInt(hashs[i]); return new RequireHashCode(hashcodes);