mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
first version of new validation algorithm, that is a lot faster
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user