Add CoherentConfigValidator

This commit is contained in:
2023-02-28 20:04:51 +01:00
parent 73be93a4b6
commit b07f6894aa
2 changed files with 24 additions and 0 deletions

View File

@@ -36,6 +36,8 @@ public class Config {
private Pattern includePattern;
private boolean safeMode;
private Integer coherent;
private Set<String> forcedKeywords = new HashSet<>(Arrays.asList("forced", "signs", "songs"));
private Set<String> commentaryKeywords = new HashSet<>(Arrays.asList("commentary", "director"));
private Set<String> excludedDirectories = new HashSet<>();

View File

@@ -0,0 +1,22 @@
package at.pcgamingfreaks.mkvaudiosubtitlechanger.config.validator;
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ConfigProperty;
import org.apache.commons.lang3.math.NumberUtils;
public class CoherentConfigValidator extends ConfigValidator<Integer> {
private static final Integer DISABLED = -1;
public CoherentConfigValidator(ConfigProperty property, boolean required) {
super(property, required, null);
}
@Override
Integer parse(String value) {
return NumberUtils.isParsable(value) ? Integer.parseInt(value) : DISABLED;
}
@Override
boolean isValid(Integer result) {
return result > 0;
}
}