This commit is contained in:
parent
86b832d03c
commit
d5349a6e5e
1 changed files with 19 additions and 17 deletions
|
|
@ -103,26 +103,28 @@ public final class ValidateSymbolsRule<R> implements IValidationRule<ImdgValidat
|
||||||
String forHash = validationSymbols.stream().map(ValidationSymbols::getSymbols).collect(Collectors.joining());
|
String forHash = validationSymbols.stream().map(ValidationSymbols::getSymbols).collect(Collectors.joining());
|
||||||
Integer hash = forHash.hashCode();
|
Integer hash = forHash.hashCode();
|
||||||
if (!Objects.equals(allowedSymbolsHash.get(), hash)) {
|
if (!Objects.equals(allowedSymbolsHash.get(), hash)) {
|
||||||
Matcher matcher = rangePattern.matcher(forHash);
|
for (ValidationSymbols symbols : validationSymbols) {
|
||||||
Set<Character> currAllowedSymbols = new HashSet<>();
|
Matcher matcher = rangePattern.matcher(symbols.getSymbols());
|
||||||
while (matcher.find()) {
|
Set<Character> currAllowedSymbols = new HashSet<>();
|
||||||
String part = matcher.group();
|
while (matcher.find()) {
|
||||||
if (part.length() == 3 && part.charAt(1) == '-') {
|
String part = matcher.group();
|
||||||
char start = part.charAt(0);
|
if (part.length() == 3 && part.charAt(1) == '-') {
|
||||||
char end = part.charAt(2);
|
char start = part.charAt(0);
|
||||||
if (start > end) {
|
char end = part.charAt(2);
|
||||||
log.warn("Invalid character range: {}, skipped", part);
|
if (start > end) {
|
||||||
continue;
|
log.warn("Invalid character range: {}, skipped", part);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (char c = start; c <= end; c++) {
|
||||||
|
currAllowedSymbols.add(c);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currAllowedSymbols.add(part.charAt(0));
|
||||||
}
|
}
|
||||||
for (char c = start; c <= end; c++) {
|
|
||||||
currAllowedSymbols.add(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currAllowedSymbols.add(part.charAt(0));
|
|
||||||
}
|
}
|
||||||
|
allowedSymbols.set(currAllowedSymbols);
|
||||||
|
allowedSymbolsHash.set(hash);
|
||||||
}
|
}
|
||||||
allowedSymbols.set(currAllowedSymbols);
|
|
||||||
allowedSymbolsHash.set(hash);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue