mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-12 02:25:59 +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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user