feat: annotation string processors (#353)

adds a system for processing strings found in annotations before they're used by AnnotationParser

implements #347

Also, because we're using "-Werror", the code won't actually build (and thus tests won't work) using JDK18. To remedy this, a bunch of @SuppressWarnings("serial")s has been added to the exceptions. We don't serialize exceptions, and they're in fact non-serializable because of their members, so this is the appropriate solution (well, the better solution would be to make them serializable, but that's outside the scope of this PR).
This commit is contained in:
Alexander Söderberg 2022-05-26 06:53:54 +02:00 committed by Jason
parent ed7b7569a8
commit d681ba5840
28 changed files with 715 additions and 38 deletions

View file

@ -112,6 +112,7 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
/**
* Exception thrown when input fails regex matching in {@link RegexPreprocessor}
*/
@SuppressWarnings("serial")
public static final class RegexValidationException extends IllegalArgumentException {
private static final long serialVersionUID = 747826566058072233L;

View file

@ -290,6 +290,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
/**
* Byte parse exception
*/
@SuppressWarnings("serial")
public static final class ByteParseException extends NumberParseException {
private static final long serialVersionUID = -4724241304872989208L;

View file

@ -279,6 +279,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
}
@SuppressWarnings("serial")
public static final class DoubleParseException extends NumberParseException {
private static final long serialVersionUID = 1764554911581976586L;

View file

@ -274,6 +274,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
}
@SuppressWarnings("serial")
public static final class FloatParseException extends NumberParseException {
private static final long serialVersionUID = -1162983846751812292L;

View file

@ -337,6 +337,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
}
@SuppressWarnings("serial")
public static final class IntegerParseException extends NumberParseException {
private static final long serialVersionUID = -6933923056628373853L;

View file

@ -282,6 +282,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
}
@SuppressWarnings("serial")
public static final class LongParseException extends NumberParseException {
private static final long serialVersionUID = 4366856282301198232L;

View file

@ -279,6 +279,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
}
@SuppressWarnings("serial")
public static final class ShortParseException extends NumberParseException {
private static final long serialVersionUID = -478674263339091032L;

View file

@ -36,7 +36,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* is being inserted into a {@link CommandTree} and an ambiguity
* is detected.
*/
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "serial"})
public final class AmbiguousNodeException extends IllegalStateException {
private static final long serialVersionUID = -200207173805584709L;

View file

@ -32,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @since 1.2.0
*/
@SuppressWarnings("serial")
public class CommandExecutionException extends IllegalArgumentException {
private static final long serialVersionUID = -4785446899438294661L;

View file

@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Exception thrown when parsing user input into a command
*/
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "serial"})
public class CommandParseException extends IllegalArgumentException {
private static final long serialVersionUID = -2415981126382517435L;

View file

@ -32,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Exception thrown when an invalid command sender tries to execute a command
*/
@SuppressWarnings("serial")
public final class InvalidCommandSenderException extends CommandParseException {
private static final long serialVersionUID = 7372142477529875598L;

View file

@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* Thrown when a {@link CommandArgument}
* that is registered as a leaf node, does not contain an owning {@link Command}
*/
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "serial"})
public final class NoCommandInLeafException extends IllegalStateException {
private static final long serialVersionUID = 3373529875213310821L;

View file

@ -33,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* Exception thrown when a command sender misses a permission required
* to execute a {@link Command}
*/
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "serial"})
public class NoPermissionException extends CommandParseException {
private static final long serialVersionUID = 7103413337750692843L;

View file

@ -29,6 +29,7 @@ import cloud.commandframework.context.CommandContext;
import java.util.Arrays;
import org.checkerframework.checker.nullness.qual.NonNull;
@SuppressWarnings("serial")
public class ParserException extends IllegalArgumentException {
private static final long serialVersionUID = -4409795575435072170L;