first version of new validation algorithm, that is a lot faster

This commit is contained in:
2016-08-07 16:57:55 +02:00
parent 4c4d25f3b5
commit bc59f08bbb
19 changed files with 454 additions and 169 deletions

View File

@@ -0,0 +1,29 @@
package ninja.javafx.smartcsv.validation;
import java.util.HashMap;
/**
* Created by abi on 07.08.2016.
*/
public class UniqueValidation implements Validation {
private HashMap<String, Integer> columnValueMap = new HashMap<>();
@Override
public void check(int row, String value, ValidationError error) {
Integer valueInLineNumber = columnValueMap.get(value);
if (valueInLineNumber != null) {
if (!valueInLineNumber.equals(row)) {
valueInLineNumber += 1; // show not 0 based line numbers to user
error.add("validation.message.uniqueness", value, valueInLineNumber.toString());
}
} else {
columnValueMap.put(value, row);
}
}
@Override
public Type getType() {
return Type.UNIQUE;
}
}