mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Fix PatternValidator & Add PatternValidatorTest
This commit is contained in:
@@ -6,6 +6,8 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class PatternValidator extends ConfigValidator<Pattern> {
|
||||
private static final Pattern EMPTY_PATTERN = Pattern.compile("");
|
||||
|
||||
public PatternValidator(ConfigProperty property, boolean required, Pattern defaultValue) {
|
||||
super(property, required, defaultValue);
|
||||
}
|
||||
@@ -15,12 +17,12 @@ public class PatternValidator extends ConfigValidator<Pattern> {
|
||||
try {
|
||||
return Pattern.compile(value);
|
||||
} catch (PatternSyntaxException e) {
|
||||
return null;
|
||||
return EMPTY_PATTERN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isValid(Pattern result) {
|
||||
return result != null;
|
||||
return !result.equals(EMPTY_PATTERN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public enum ConfigProperty {
|
||||
SAFE_MODE("safe-mode", "s", "Test run (no files will be changes)"),
|
||||
WINDOWS("windows", null, "Is operating system windows"),
|
||||
THREADS("threads", "t", "thread count (default: 2)"),
|
||||
INCLUDE_PATTERN("include-pattern", "i", "Include files matching pattern"),
|
||||
INCLUDE_PATTERN("include-pattern", "p", "Include files matching pattern"),
|
||||
MKV_TOOL_NIX("mkvtoolnix", "m", "Path to mkv tool nix installation"),
|
||||
FORCED_KEYWORDS("forcedKeywords", "fk", "Additional keywords to identify forced tracks"),
|
||||
COMMENTARY_KEYWORDS("commentary-keywords", "ck", "Additional keywords to identify commentary tracks"),
|
||||
|
||||
Reference in New Issue
Block a user