fixed uniqueness validation and renamed the abstract class when empty values are valid

This commit is contained in:
2016-08-09 21:17:29 +02:00
parent c7873ef0ba
commit 7472c66823
11 changed files with 13 additions and 13 deletions

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.matchRegexp;
/**
* Checks if the value is alpha numeric
*/
public class AlphaNumericValidation extends EmptyAllowedValidation {
public class AlphaNumericValidation extends EmptyValueIsValid {
@Override
public void check(int row, String value, ValidationError error) {
if (!matchRegexp(value, "[0-9a-zA-Z]*")) {

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isDate;
/**
* Checks if the date has the right format
*/
public class DateValidation extends EmptyAllowedValidation {
public class DateValidation extends EmptyValueIsValid {
private String dateformat;

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isDouble;
/**
* Checks if the value is a double
*/
public class DoubleValidation extends EmptyAllowedValidation {
public class DoubleValidation extends EmptyValueIsValid {
@Override
public void check(int row, String value, ValidationError error) {

View File

@@ -1,9 +1,9 @@
package ninja.javafx.smartcsv.validation;
/**
* Created by abi on 09.08.2016.
* validations based on this are not validated when the value is null or empty
*/
public abstract class EmptyAllowedValidation implements Validation {
public abstract class EmptyValueIsValid implements Validation {
@Override
public boolean canBeChecked(String value) {

View File

@@ -33,7 +33,7 @@ import org.codehaus.groovy.control.CompilationFailedException;
/**
* Executes the given groovy as check
*/
public class GroovyValidation extends EmptyAllowedValidation {
public class GroovyValidation extends EmptyValueIsValid {
private String groovyScript;
private GroovyShell shell = new GroovyShell();

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.isInt;
/**
* Checks if the value is an integer
*/
public class IntegerValidation extends EmptyAllowedValidation {
public class IntegerValidation extends EmptyValueIsValid {
@Override
public void check(int row, String value, ValidationError error) {

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.maxLength;
/**
* Checks if the value is shorter or exactly as long as the given max length
*/
public class MaxLengthValidation extends EmptyAllowedValidation {
public class MaxLengthValidation extends EmptyValueIsValid {
private int maxLength;

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.minLength;
/**
* Checks if the value is at minimum long as the given min length
*/
public class MinLengthValidation extends EmptyAllowedValidation {
public class MinLengthValidation extends EmptyValueIsValid {
private int minLength;

View File

@@ -30,7 +30,7 @@ import static org.apache.commons.validator.GenericValidator.matchRegexp;
/**
* Checks the value against the given reg exp
*/
public class RegExpValidation extends EmptyAllowedValidation {
public class RegExpValidation extends EmptyValueIsValid {
private String regexp;

View File

@@ -36,7 +36,7 @@ import static java.util.stream.Collectors.joining;
/**
* Checks if the value is unique in the column
*/
public class UniqueValidation extends EmptyAllowedValidation {
public class UniqueValidation extends EmptyValueIsValid {
private ColumnValueProvider columnValueProvider;
private String column;
@@ -55,7 +55,7 @@ public class UniqueValidation extends EmptyAllowedValidation {
for (int currentRowOfIteration = 0; currentRowOfIteration < numberOfRows; currentRowOfIteration++) {
String storedValue = columnValueProvider.getValue(currentRowOfIteration, column);
if (storedValue.equals(value) && currentRowOfIteration != row) {
if (value.equals(storedValue) && currentRowOfIteration != row) {
lineNumbers.add(currentRowOfIteration + 1); // show not 0 based line numbers to user
}
}

View File

@@ -32,7 +32,7 @@ import static java.util.stream.Collectors.joining;
/**
* Checks if the value is part of a list of values
*/
public class ValueOfValidation extends EmptyAllowedValidation {
public class ValueOfValidation extends EmptyValueIsValid {
private List<String> values;