core: Throw an exception when both GREEDY and QUOTED are specified for a StringArgument

This commit is contained in:
jmp 2021-03-17 21:11:44 -07:00 committed by Jason
parent 1bed15ea6d
commit c78c4aba08

View file

@ -136,6 +136,11 @@ public final class StandardParserRegistry<C> implements ParserRegistry<C> {
this.registerParserSupplier(TypeToken.get(String.class), options -> { this.registerParserSupplier(TypeToken.get(String.class), options -> {
final boolean greedy = options.get(StandardParameters.GREEDY, false); final boolean greedy = options.get(StandardParameters.GREEDY, false);
final boolean quoted = options.get(StandardParameters.QUOTED, false); final boolean quoted = options.get(StandardParameters.QUOTED, false);
if (greedy && quoted) {
throw new IllegalArgumentException(
"Don't know whether to create GREEDY or QUOTED StringArgument.StringParser, both specified."
);
}
final StringArgument.StringMode stringMode; final StringArgument.StringMode stringMode;
if (greedy) { if (greedy) {
stringMode = StringArgument.StringMode.GREEDY; stringMode = StringArgument.StringMode.GREEDY;