Adding line breaks and exception cleanup

This commit is contained in:
broccolai 2020-09-12 01:31:39 +01:00 committed by Alexander Söderberg
parent c29fea5bb3
commit 49eaa66b4e
3 changed files with 23 additions and 1 deletions

View file

@ -94,6 +94,7 @@ public final class BooleanComponent<C extends CommandSender> extends CommandComp
return BooleanComponent.<C>newBuilder(name).asOptionalWithDefault(defaultNum).build();
}
public static final class Builder<C extends CommandSender> extends CommandComponent.Builder<C, Boolean> {
private boolean liberal = false;
@ -136,6 +137,7 @@ public final class BooleanComponent<C extends CommandSender> extends CommandComp
return liberal;
}
private static final class BooleanParser<C extends CommandSender> implements ComponentParser<C, Boolean> {
private static final List<String> LIBERAL = Arrays.asList("TRUE", "YES", "ON", "FALSE", "NO", "OFF");
@ -195,8 +197,13 @@ public final class BooleanComponent<C extends CommandSender> extends CommandComp
}
}
/**
* Boolean parse exception
*/
public static final class BooleanParseException extends IllegalArgumentException {
private final String input;
private final boolean liberal;
/**
@ -206,10 +213,19 @@ public final class BooleanComponent<C extends CommandSender> extends CommandComp
* @param liberal Liberal value
*/
public BooleanParseException(@Nonnull final String input, final boolean liberal) {
super(input);
this.input = input;
this.liberal = liberal;
}
/**
* Get the supplied input
*
* @return String value
*/
public String getInput() {
return input;
}
/**
* Get the liberal boolean value
*

View file

@ -90,6 +90,7 @@ public final class CharComponent<C extends CommandSender> extends CommandCompone
return CharComponent.<C>newBuilder(name).asOptionalWithDefault(defaultNum).build();
}
public static final class Builder<C extends CommandSender> extends CommandComponent.Builder<C, Character> {
protected Builder(@Nonnull final String name) {
@ -130,6 +131,9 @@ public final class CharComponent<C extends CommandSender> extends CommandCompone
}
/**
* Char parse exception
*/
public static final class CharParseException extends IllegalArgumentException {
private final String input;

View file

@ -93,6 +93,7 @@ public final class StringComponent<C extends CommandSender> extends CommandCompo
return StringComponent.<C>newBuilder(name).asOptionalWithDefault(defaultNum).build();
}
public static final class Builder<C extends CommandSender> extends CommandComponent.Builder<C, String> {
private boolean greedy = false;
@ -135,6 +136,7 @@ public final class StringComponent<C extends CommandSender> extends CommandCompo
return greedy;
}
private static final class StringParser<C extends CommandSender> implements ComponentParser<C, String> {
private final boolean greedy;