chore(core): add apiguardian @API annotations (#368)

This commit is contained in:
Alexander Söderberg 2022-06-06 20:34:50 +02:00 committed by Jason
parent d4ab593460
commit 4360847852
119 changed files with 531 additions and 17 deletions

View file

@ -24,6 +24,7 @@
package cloud.commandframework;
import cloud.commandframework.arguments.CommandArgument;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import static java.util.Objects.requireNonNull;
@ -33,6 +34,7 @@ import static java.util.Objects.requireNonNull;
*
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public interface ArgumentDescription {
/**

View file

@ -48,6 +48,7 @@ import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -56,6 +57,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public class Command<C> {
private final List<@NonNull CommandComponent<C>> components;
@ -75,6 +77,7 @@ public class Command<C> {
* @param commandMeta Command meta instance
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public Command(
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -118,6 +121,7 @@ public class Command<C> {
* @param commandMeta Command meta instance
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public Command(
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -136,6 +140,7 @@ public class Command<C> {
* @param commandMeta Command meta instance
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public Command(
final @NonNull List<@NonNull CommandComponent<C>> commandComponents,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -157,6 +162,7 @@ public class Command<C> {
* @see #Command(List, CommandExecutionHandler, Class, CommandPermission, CommandMeta)
*/
@Deprecated
@API(status = API.Status.DEPRECATED)
public Command(
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -178,6 +184,7 @@ public class Command<C> {
* @see #Command(List, CommandExecutionHandler, Class, CommandMeta)
*/
@Deprecated
@API(status = API.Status.DEPRECATED)
public Command(
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -198,6 +205,7 @@ public class Command<C> {
* @see #Command(List, CommandExecutionHandler, CommandPermission, CommandMeta)
*/
@Deprecated
@API(status = API.Status.DEPRECATED)
public Command(
final @NonNull Map<@NonNull CommandArgument<C, ?>, @NonNull Description> commandArguments,
final @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
@ -231,6 +239,7 @@ public class Command<C> {
* @deprecated for removal since 1.4.0. Use {@link #newBuilder(String, CommandMeta, ArgumentDescription, String...)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public static <C> @NonNull Builder<C> newBuilder(
final @NonNull String commandName,
final @NonNull CommandMeta commandMeta,
@ -252,6 +261,7 @@ public class Command<C> {
* @return Command builder
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public static <C> @NonNull Builder<C> newBuilder(
final @NonNull String commandName,
final @NonNull CommandMeta commandMeta,
@ -314,6 +324,7 @@ public class Command<C> {
* @return Copy of the command component array. This List is mutable
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public @NonNull List<CommandComponent<@NonNull C>> getComponents() {
return new ArrayList<>(this.components);
}
@ -364,6 +375,7 @@ public class Command<C> {
* Use {@link #getArguments()} and search in that, instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED)
public @NonNull String getArgumentDescription(final @NonNull CommandArgument<C, ?> argument) {
for (final CommandComponent<C> component : this.components) {
if (component.getArgument().equals(argument)) {
@ -384,7 +396,7 @@ public class Command<C> {
}
/**
* Check whether or not the command is hidden
* Check whether the command is hidden
*
* @return {@code true} if the command is hidden, {@code false} if not
*/
@ -399,6 +411,7 @@ public class Command<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class Builder<C> {
private final CommandMeta commandMeta;
@ -435,6 +448,7 @@ public class Command<C> {
* @return required sender type
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public @Nullable Class<? extends C> senderType() {
return this.senderType;
}
@ -447,6 +461,7 @@ public class Command<C> {
* @return required permission
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public @NonNull CommandPermission commandPermission() {
return this.commandPermission;
}
@ -460,6 +475,7 @@ public class Command<C> {
* @deprecated for removal since 1.2.0, use the typesafe variant at {@link #meta(CommandMeta.Key, Object)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.2.0")
public @NonNull Builder<C> meta(final @NonNull String key, final @NonNull String value) {
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
return new Builder<>(
@ -482,6 +498,7 @@ public class Command<C> {
* @return New builder instance using the inserted meta key-value pair
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public <V> @NonNull Builder<C> meta(final CommandMeta.@NonNull Key<V> key, final @NonNull V value) {
final CommandMeta commandMeta = SimpleCommandMeta.builder().with(this.commandMeta).with(key, value).build();
return new Builder<>(
@ -539,6 +556,7 @@ public class Command<C> {
* @deprecated for removal since 1.4.0. Use {@link #literal(String, ArgumentDescription, String...)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public @NonNull Builder<C> literal(
final @NonNull String main,
final @NonNull Description description,
@ -556,6 +574,7 @@ public class Command<C> {
* @return New builder instance with the modified command chain
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull Builder<C> literal(
final @NonNull String main,
final @NonNull ArgumentDescription description,
@ -597,6 +616,7 @@ public class Command<C> {
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <T> @NonNull Builder<C> argument(
final @NonNull CommandArgument<C, T> argument,
final @NonNull Description description
@ -613,6 +633,7 @@ public class Command<C> {
* @return New builder instance with the command argument inserted into the argument list
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull Builder<C> argument(
final @NonNull CommandArgument<C, T> argument,
final @NonNull ArgumentDescription description
@ -646,6 +667,7 @@ public class Command<C> {
* @deprecated for removal since 1.4.0. Use {@link #argument(CommandArgument.Builder, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <T> @NonNull Builder<C> argument(
final CommandArgument.@NonNull Builder<C, T> builder,
final @NonNull Description description
@ -663,6 +685,7 @@ public class Command<C> {
* @return New builder instance with the command argument inserted into the argument list
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull Builder<C> argument(
final CommandArgument.@NonNull Builder<C, T> builder,
final @NonNull ArgumentDescription description
@ -723,6 +746,7 @@ public class Command<C> {
* @deprecated for removal since 1.4.0. Use {@link #argumentPair(String, Pair, Pair, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <U, V> @NonNull Builder<C> argumentPair(
final @NonNull String name,
final @NonNull Pair<@NonNull String, @NonNull String> names,
@ -750,6 +774,7 @@ public class Command<C> {
* @return Builder instance with the argument inserted
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <U, V> @NonNull Builder<C> argumentPair(
final @NonNull String name,
final @NonNull Pair<@NonNull String, @NonNull String> names,
@ -785,6 +810,7 @@ public class Command<C> {
* {@link #argumentPair(String, TypeToken, Pair, Pair, BiFunction, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <U, V, O> @NonNull Builder<C> argumentPair(
final @NonNull String name,
final @NonNull TypeToken<O> outputType,
@ -817,6 +843,7 @@ public class Command<C> {
* @return Builder instance with the argument inserted
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <U, V, O> @NonNull Builder<C> argumentPair(
final @NonNull String name,
final @NonNull TypeToken<O> outputType,
@ -855,6 +882,7 @@ public class Command<C> {
* instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <U, V, W> @NonNull Builder<C> argumentTriplet(
final @NonNull String name,
final @NonNull Triplet<String, String, String> names,
@ -883,6 +911,7 @@ public class Command<C> {
* @return Builder instance with the argument inserted
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <U, V, W> @NonNull Builder<C> argumentTriplet(
final @NonNull String name,
final @NonNull Triplet<String, String, String> names,
@ -919,6 +948,7 @@ public class Command<C> {
* {@link #argumentTriplet(String, TypeToken, Triplet, Triplet, BiFunction, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
final @NonNull String name,
final @NonNull TypeToken<O> outputType,
@ -959,6 +989,7 @@ public class Command<C> {
* @return Builder instance with the argument inserted
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <U, V, W, O> @NonNull Builder<C> argumentTriplet(
final @NonNull String name,
final @NonNull TypeToken<O> outputType,
@ -1002,6 +1033,7 @@ public class Command<C> {
* @return the current handler
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public @NonNull CommandExecutionHandler<C> handler() {
return this.commandExecutionHandler;
}

View file

@ -25,6 +25,7 @@ package cloud.commandframework;
import cloud.commandframework.arguments.CommandArgument;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <C> Command sender type
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public final class CommandComponent<C> {
private final CommandArgument<C, ?> argument;
@ -68,6 +70,7 @@ public final class CommandComponent<C> {
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public @NonNull Description getDescription() {
if (this.description instanceof Description) {
return (Description) this.description;
@ -82,6 +85,7 @@ public final class CommandComponent<C> {
* @return command component description
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull ArgumentDescription getArgumentDescription() {
return this.description;
}
@ -120,6 +124,7 @@ public final class CommandComponent<C> {
* @deprecated for removal since 1.4.0. Use {@link #of(CommandArgument, ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public static <C> @NonNull CommandComponent<C> of(
final @NonNull CommandArgument<C, ?> commandArgument,
final @NonNull Description commandDescription

View file

@ -36,9 +36,11 @@ import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@API(status = API.Status.STABLE)
public final class CommandHelpHandler<C> {
private final CommandManager<C> commandManager;
@ -289,6 +291,7 @@ public final class CommandHelpHandler<C> {
return false;
}
/**
* Something that can be returned as the result of a help query
* <p>
@ -301,10 +304,13 @@ public final class CommandHelpHandler<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface HelpTopic<C> {
}
@API(status = API.Status.STABLE)
public static final class VerboseHelpEntry<C> {
private final Command<C> command;
@ -378,11 +384,13 @@ public final class CommandHelpHandler<C> {
}
/**
* Index of available commands
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class IndexHelpTopic<C> implements HelpTopic<C> {
private final List<VerboseHelpEntry<C>> entries;
@ -441,6 +449,7 @@ public final class CommandHelpHandler<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class VerboseHelpTopic<C> implements HelpTopic<C> {
private final Command<C> command;
@ -503,6 +512,7 @@ public final class CommandHelpHandler<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class MultiHelpTopic<C> implements HelpTopic<C> {
private final String longestPath;

View file

@ -75,6 +75,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.function.Predicate;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@ -84,6 +85,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public abstract class CommandManager<C> {
private final Map<Class<? extends Exception>, BiConsumer<C, ? extends Exception>> exceptionHandlers = new HashMap<>();
@ -250,6 +252,7 @@ public abstract class CommandManager<C> {
* @return the caption variable replacement handler
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler() {
return this.captionVariableReplacementHandler;
}
@ -260,6 +263,7 @@ public abstract class CommandManager<C> {
* @param captionVariableReplacementHandler new replacement handler
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public void captionVariableReplacementHandler(
final @NonNull CaptionVariableReplacementHandler captionVariableReplacementHandler
) {
@ -363,6 +367,7 @@ public abstract class CommandManager<C> {
* @deprecated Use {@link #setCaptionRegistry(CaptionRegistry)} These methods are identical.
*/
@Deprecated
@API(status = API.Status.DEPRECATED)
public final void registerDefaultCaptions(final @NonNull CaptionRegistry<C> captionRegistry) {
this.captionRegistry = captionRegistry;
}
@ -392,9 +397,11 @@ public abstract class CommandManager<C> {
* @param description Description for the root literal
* @param meta Command meta
* @return Builder instance
* @deprecated for removal since 1.4.0. Use {@link #commandBuilder(String, Collection, Description, CommandMeta)} instead.
* @deprecated for removal since 1.4.0. Use
* {@link #commandBuilder(String, Collection, ArgumentDescription, CommandMeta)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull Collection<String> aliases,
@ -421,6 +428,7 @@ public abstract class CommandManager<C> {
* @return Builder instance
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull Collection<String> aliases,
@ -484,6 +492,7 @@ public abstract class CommandManager<C> {
* instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull CommandMeta meta,
@ -510,6 +519,7 @@ public abstract class CommandManager<C> {
* @return Builder instance
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull CommandMeta meta,
@ -575,6 +585,7 @@ public abstract class CommandManager<C> {
* @deprecated for removal since 1.4.0. Use {@link #commandBuilder(String, ArgumentDescription, String...)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull Description description,
@ -603,6 +614,7 @@ public abstract class CommandManager<C> {
* @see #createDefaultCommandMeta() Default command meta creation
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public Command.@NonNull Builder<C> commandBuilder(
final @NonNull String name,
final @NonNull ArgumentDescription description,
@ -943,6 +955,7 @@ public abstract class CommandManager<C> {
* @return Command execution coordinator
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public @NonNull CommandExecutionCoordinator<C> commandExecutionCoordinator() {
return this.commandExecutionCoordinator;
}
@ -955,6 +968,7 @@ public abstract class CommandManager<C> {
* @throws IllegalStateException if the manager is in any state but {@code in} or {@code out}
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
protected final void transitionOrThrow(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
if (!this.transitionIfPossible(in, out)) {
throw new IllegalStateException("Command manager was in state " + this.state.get() + ", while we were expecting a state "
@ -970,6 +984,7 @@ public abstract class CommandManager<C> {
* @return {@code true} if the state transition was successful, or the manager was already in the desired state
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
protected final boolean transitionIfPossible(final @NonNull RegistrationState in, final @NonNull RegistrationState out) {
return this.state.compareAndSet(in, out) || this.state.get() == out;
}
@ -981,6 +996,7 @@ public abstract class CommandManager<C> {
* @throws IllegalStateException if the manager is not in the expected state
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
protected final void requireState(final @NonNull RegistrationState expected) {
if (this.state.get() != expected) {
throw new IllegalStateException("This operation required the commands manager to be in state " + expected + ", but it "
@ -995,6 +1011,7 @@ public abstract class CommandManager<C> {
* @throws IllegalStateException if the manager is not in the expected state
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
protected final void lockRegistration() {
if (this.getRegistrationState() == RegistrationState.BEFORE_REGISTRATION) {
this.transitionOrThrow(RegistrationState.BEFORE_REGISTRATION, RegistrationState.AFTER_REGISTRATION);
@ -1011,6 +1028,7 @@ public abstract class CommandManager<C> {
* @return The current state
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public final @NonNull RegistrationState getRegistrationState() {
return this.state.get();
}
@ -1024,16 +1042,19 @@ public abstract class CommandManager<C> {
* @return {@code true} if the registration is allowed, else {@code false}
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public boolean isCommandRegistrationAllowed() {
return this.getSetting(ManagerSettings.ALLOW_UNSAFE_REGISTRATION) || this.state.get() != RegistrationState.AFTER_REGISTRATION;
}
/**
* Configurable command related settings
*
* @see CommandManager#setSetting(ManagerSettings, boolean) Set a manager setting
* @see CommandManager#getSetting(ManagerSettings) Get a manager setting
*/
@API(status = API.Status.STABLE)
public enum ManagerSettings {
/**
* Do not create a compound permission and do not look greedily
@ -1057,6 +1078,7 @@ public abstract class CommandManager<C> {
*
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
ALLOW_UNSAFE_REGISTRATION,
/**
@ -1064,14 +1086,17 @@ public abstract class CommandManager<C> {
*
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
OVERRIDE_EXISTING_COMMANDS
}
/**
* The point in the registration lifecycle for this commands manager
*
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public enum RegistrationState {
/**
* The point when no commands have been registered yet.

View file

@ -60,6 +60,7 @@ import java.util.Queue;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -90,6 +91,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class CommandTree<C> {
/**

View file

@ -24,6 +24,7 @@
package cloud.commandframework;
import cloud.commandframework.arguments.CommandArgument;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @deprecated to become package-private since 1.4.0. Use {@link ArgumentDescription} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public final class Description implements ArgumentDescription {
/**

View file

@ -27,6 +27,7 @@ import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.internal.CommandRegistrationHandler;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @deprecated Use a normal {@link CommandManager}'s registration state instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.2.0")
public abstract class LockableCommandManager<C> extends CommandManager<C> {
/**

View file

@ -29,9 +29,11 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
final class AnnotatedElementAccessor implements AnnotationAccessor {
private final AnnotatedElement element;

View file

@ -27,6 +27,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Collection;
import java.util.Collections;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -35,6 +36,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public interface AnnotationAccessor {
/**
@ -43,6 +45,7 @@ public interface AnnotationAccessor {
* @return Empty annotation accessor
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
static @NonNull AnnotationAccessor empty() {
return new NullAnnotationAccessor();
}
@ -67,6 +70,7 @@ public interface AnnotationAccessor {
* @return Annotation accessor that delegates to the given accessors (using their natural ordering)
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
static @NonNull AnnotationAccessor of(final @NonNull AnnotationAccessor@NonNull... accessors) {
return new MultiDelegateAnnotationAccessor(accessors);
}
@ -95,6 +99,7 @@ public interface AnnotationAccessor {
*
* @since 1.3.0
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.3.0")
final class NullAnnotationAccessor implements AnnotationAccessor {
@Override

View file

@ -28,9 +28,11 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
private final AnnotationAccessor[] accessors;

View file

@ -28,6 +28,7 @@ import cloud.commandframework.context.CommandContext;
import cloud.commandframework.types.tuples.Triplet;
import com.google.inject.ConfigurationException;
import com.google.inject.Injector;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <C> Command sender type
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public final class GuiceInjectionService<C> implements InjectionService<C> {
private final Injector injector;

View file

@ -27,6 +27,7 @@ import cloud.commandframework.annotations.AnnotationAccessor;
import cloud.commandframework.context.CommandContext;
import cloud.commandframework.services.types.Service;
import cloud.commandframework.types.tuples.Triplet;
import org.apiguardian.api.API;
/**
* Service that can be registered to the {@link ParameterInjectorRegistry} in order to provide
@ -37,6 +38,7 @@ import cloud.commandframework.types.tuples.Triplet;
* @since 1.4.0
*/
@FunctionalInterface
@API(status = API.Status.STABLE, since = "1.4.0")
public interface InjectionService<C> extends
Service<Triplet<CommandContext<C>, Class<?>, AnnotationAccessor>, Object> {

View file

@ -25,6 +25,7 @@ package cloud.commandframework.annotations.injection;
import cloud.commandframework.annotations.AnnotationAccessor;
import cloud.commandframework.context.CommandContext;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @since 1.2.0
*/
@FunctionalInterface
@API(status = API.Status.STABLE, since = "1.2.0")
public interface ParameterInjector<C, T> {
/**

View file

@ -36,6 +36,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -46,6 +47,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @since 1.2.0
*/
@SuppressWarnings("ALL")
@API(status = API.Status.STABLE, since = "1.2.0")
public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
private volatile int injectorCount = 0;
@ -124,6 +126,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
* @since 1.4.0
*/
@SuppressWarnings("EmptyCatch")
@API(status = API.Status.STABLE, since = "1.4.0")
public <@NonNull T> @NonNull Optional<T> getInjectable(
final @NonNull Class<T> clazz,
final @NonNull CommandContext<C> context,
@ -145,6 +148,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
* @param service Service implementation
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public void registerInjectionService(final InjectionService<C> service) {
this.servicePipeline.registerServiceImplementation(new TypeToken<InjectionService<C>>() {
}, service, Collections.emptyList());

View file

@ -28,12 +28,14 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
/**
* Command completions, separated by "," or ", "
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@API(status = API.Status.STABLE)
public @interface Completions {
/**

View file

@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
/**
* Indicates that the argument should stop parsing when encountering what
@ -38,6 +39,7 @@ import java.lang.annotation.Target;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@API(status = API.Status.STABLE, since = "1.7.0")
public @interface FlagYielding {
}

View file

@ -27,12 +27,14 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
/**
* Annotation used to make {@link cloud.commandframework.arguments.standard.StringArgument string arguments} greedy
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@API(status = API.Status.STABLE)
public @interface Greedy {
}

View file

@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
/**
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.BooleanArgument boolean
@ -36,6 +37,7 @@ import java.lang.annotation.Target;
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@API(status = API.Status.STABLE, since = "1.6.0")
public @interface Liberal {
}

View file

@ -27,6 +27,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
/**
* Annotation used to set the parsing mode of a {@link cloud.commandframework.arguments.standard.StringArgument string
@ -36,6 +37,7 @@ import java.lang.annotation.Target;
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@API(status = API.Status.STABLE, since = "1.5.0")
public @interface Quoted {
}

View file

@ -28,6 +28,7 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -36,6 +37,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@API(status = API.Status.STABLE)
public @interface Range {
/**

View file

@ -42,6 +42,7 @@ import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import java.util.regex.Pattern;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@ -53,6 +54,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
* @param <T> The type that the argument parses into
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>, CloudKeyHolder<T> {
/**
@ -126,6 +128,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @param argumentPreprocessors Argument preprocessors
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public CommandArgument(
final boolean required,
final @NonNull String name,
@ -219,6 +222,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @param defaultDescription Default description to use when registering
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public CommandArgument(
final boolean required,
final @NonNull String name,
@ -265,6 +269,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @param defaultDescription Default description to use when registering
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public CommandArgument(
final boolean required,
final @NonNull String name,
@ -281,7 +286,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
/**
* Construct a new command argument
*
* @param required Whether or not the argument is required
* @param required Whether the argument is required
* @param name The argument name
* @param parser The argument parser
* @param valueType Type produced by the parser
@ -417,8 +422,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
*
* @return Owning command
*/
@Nullable
public Command<C> getOwningCommand() {
public @Nullable Command<C> getOwningCommand() {
return this.owningCommand;
}
@ -537,7 +541,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
}
/**
* Check whether or not the argument has been used in a command
* Check whether the argument has been used in a command
*
* @return {@code true} if the argument has been used in a command, else {@code false}
*/
@ -559,6 +563,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @param <C> Command sender type
* @param <T> Argument value type
*/
@API(status = API.Status.STABLE)
public static class Builder<C, T> {
private final TypeToken<T> valueType;
@ -679,6 +684,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @return Builder instance
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull @This Builder<@NonNull C, @NonNull T> withDefaultDescription(
final @NonNull ArgumentDescription defaultDescription
) {
@ -753,6 +759,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
* @param <B> the subclass type
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public abstract static class TypedBuilder<C, T, B extends Builder<C, T>> extends Builder<C, T> {
protected TypedBuilder(

View file

@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
import cloud.commandframework.context.CommandContext;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface CommandSuggestionEngine<C> {
/**

View file

@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
import cloud.commandframework.CommandTree;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -34,6 +35,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <C> Command sender type
*/
@FunctionalInterface
@API(status = API.Status.STABLE)
public interface CommandSyntaxFormatter<C> {
/**

View file

@ -32,6 +32,7 @@ import cloud.commandframework.services.State;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -39,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class DelegatingCommandSuggestionEngine<C> implements CommandSuggestionEngine<C> {
private static final List<String> SINGLE_EMPTY_SUGGESTION = Collections.unmodifiableList(Collections.singletonList(""));

View file

@ -25,6 +25,7 @@ package cloud.commandframework.arguments;
import cloud.commandframework.CommandManager;
import cloud.commandframework.CommandTree;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class DelegatingCommandSuggestionEngineFactory<C> {
private final CommandManager<C> commandManager;

View file

@ -27,8 +27,10 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
import cloud.commandframework.context.CommandContext;
import java.util.List;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
final class DelegatingSuggestionsProvider<C> implements BiFunction<@NonNull CommandContext<C>,
@NonNull String, @NonNull List<String>> {

View file

@ -29,6 +29,7 @@ import cloud.commandframework.arguments.compound.FlagArgument;
import cloud.commandframework.arguments.flags.CommandFlag;
import java.util.Iterator;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public class StandardCommandSyntaxFormatter<C> implements CommandSyntaxFormatter<C> {
/**
@ -132,6 +134,7 @@ public class StandardCommandSyntaxFormatter<C> implements CommandSyntaxFormatter
/**
* Instance that is used when building command syntax
*/
@API(status = API.Status.STABLE)
public static class FormattingInstance {
private final StringBuilder builder;

View file

@ -35,6 +35,7 @@ import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.TreeSet;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class StaticArgument<C> extends CommandArgument<C, String> {
private StaticArgument(final boolean required, final @NonNull String name, final @NonNull String... aliases) {

View file

@ -30,6 +30,7 @@ import cloud.commandframework.arguments.parser.ParserRegistry;
import cloud.commandframework.types.tuples.Pair;
import io.leangen.geantyref.TypeToken;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -40,6 +41,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <V> Second argument type
* @param <O> Output type
*/
@API(status = API.Status.STABLE)
public class ArgumentPair<C, U, V, O> extends CompoundArgument<Pair<U, V>, C, O> {
/**
@ -104,7 +106,9 @@ public class ArgumentPair<C, U, V, O> extends CompoundArgument<Pair<U, V>, C, O>
return new ArgumentPairIntermediaryBuilder<>(true, name, names, Pair.of(firstParser, secondaryParser), types);
}
@SuppressWarnings("ALL")
@API(status = API.Status.STABLE)
public static final class ArgumentPairIntermediaryBuilder<C, U, V> {
private final boolean required;

View file

@ -30,6 +30,7 @@ import cloud.commandframework.arguments.parser.ParserRegistry;
import cloud.commandframework.types.tuples.Triplet;
import io.leangen.geantyref.TypeToken;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -41,6 +42,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <W> Third argument type
* @param <O> Output type
*/
@API(status = API.Status.STABLE)
public class ArgumentTriplet<C, U, V, W, O> extends CompoundArgument<Triplet<U, V, W>, C, O> {
/**
@ -115,7 +117,9 @@ public class ArgumentTriplet<C, U, V, W, O> extends CompoundArgument<Triplet<U,
);
}
@SuppressWarnings("ALL")
@API(status = API.Status.STABLE)
public static final class ArgumentTripletIntermediaryBuilder<C, U, V, W> {
private final boolean required;

View file

@ -33,6 +33,7 @@ import java.util.List;
import java.util.Queue;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -42,6 +43,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <C> Command sender type
* @param <O> Output type
*/
@API(status = API.Status.STABLE)
public class CompoundArgument<T extends Tuple, C, O> extends CommandArgument<C, O> {
private final Tuple types;

View file

@ -47,6 +47,7 @@ import java.util.Set;
import java.util.function.BiFunction;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -55,6 +56,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class FlagArgument<C> extends CommandArgument<C, Object> {
private static final Pattern FLAG_PRIMARY_PATTERN = Pattern.compile(" --(?<name>([A-Za-z]+))");
@ -105,6 +107,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
}
@API(status = API.Status.STABLE)
public static final class FlagArgumentParser<C> implements ArgumentParser<C, Object> {
private final CommandFlag<?>[] flags;
@ -289,6 +292,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
return this.suggestions(commandContext, input);
}
/**
* Helper class to parse the command input queue into flags
* and flag values. On failure the intermediate results
@ -472,9 +476,11 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
}
}
/**
* Flag parse exception
*/
@API(status = API.Status.STABLE)
public static final class FlagParseException extends ParserException {
private static final long serialVersionUID = -7725389394142868549L;
@ -513,9 +519,11 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
}
/**
* Reasons for which flag parsing may fail
*/
@API(status = API.Status.STABLE)
public enum FailureReason {
UNKNOWN_FLAG(StandardCaptionKeys.ARGUMENT_PARSE_FAILURE_FLAG_UNKNOWN_FLAG),

View file

@ -32,6 +32,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -43,6 +44,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <T> Command argument type. {@link Void} is used when no argument is present.
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class CommandFlag<T> {
private final @NonNull String name;
@ -101,6 +103,7 @@ public final class CommandFlag<T> {
* @deprecated for removal since 1.4.0. Use {@link #getArgumentDescription()} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public cloud.commandframework.@NonNull Description getDescription() {
if (this.description instanceof cloud.commandframework.Description) {
return ((cloud.commandframework.Description) this.description);
@ -115,6 +118,7 @@ public final class CommandFlag<T> {
* @return Flag description
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull ArgumentDescription getArgumentDescription() {
return this.description;
}
@ -134,6 +138,7 @@ public final class CommandFlag<T> {
* @return Command permission, or {@code null}
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public CommandPermission permission() {
return this.permission;
}
@ -161,6 +166,7 @@ public final class CommandFlag<T> {
}
@API(status = API.Status.STABLE)
public static final class Builder<T> {
private final String name;
@ -227,6 +233,7 @@ public final class CommandFlag<T> {
* @deprecated for removal since 1.4.0. Use {@link #withDescription(ArgumentDescription)} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.4.0")
public Builder<T> withDescription(final cloud.commandframework.@NonNull Description description) {
return this.withDescription((ArgumentDescription) description);
}
@ -238,6 +245,7 @@ public final class CommandFlag<T> {
* @return New builder instance
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public Builder<T> withDescription(final @NonNull ArgumentDescription description) {
return new Builder<>(this.name, this.aliases, description, this.permission, this.commandArgument);
}
@ -271,6 +279,7 @@ public final class CommandFlag<T> {
* @return New builder instance
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public Builder<T> withPermission(final @NonNull CommandPermission permission) {
return new Builder<>(this.name, this.aliases, this.description, permission, this.commandArgument);
}

View file

@ -26,12 +26,14 @@ package cloud.commandframework.arguments.flags;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Flag value mappings
*/
@API(status = API.Status.STABLE)
public final class FlagContext {
/**
@ -99,6 +101,7 @@ public final class FlagContext {
* else {@code false}
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public boolean isPresent(final @NonNull CommandFlag<Void> flag) {
return this.isPresent(flag.getName());
}
@ -111,6 +114,7 @@ public final class FlagContext {
* @return Optional containing stored value if present
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public <T> @NonNull Optional<T> getValue(
final @NonNull String name
) {
@ -130,6 +134,7 @@ public final class FlagContext {
* @return Optional containing stored value if present
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull Optional<T> getValue(
final @NonNull CommandFlag<T> flag
) {
@ -160,6 +165,7 @@ public final class FlagContext {
* @return Stored value, or the supplied default value
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @Nullable T getValue(
final @NonNull CommandFlag<T> name,
final @Nullable T defaultValue
@ -176,6 +182,7 @@ public final class FlagContext {
* @return whether the flag is present
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public boolean hasFlag(
final @NonNull String name
) {
@ -191,6 +198,7 @@ public final class FlagContext {
* @return whether the flag is present
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public boolean hasFlag(
final @NonNull CommandFlag<?> flag
) {
@ -206,6 +214,7 @@ public final class FlagContext {
* @return whether the flag is present
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public boolean contains(final @NonNull String name) {
return this.hasFlag(name);
}
@ -219,6 +228,7 @@ public final class FlagContext {
* @return whether the flag is present
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public boolean contains(final @NonNull CommandFlag<?> flag) {
return this.hasFlag(flag);
}
@ -232,6 +242,7 @@ public final class FlagContext {
* @since 1.3.0
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
@API(status = API.Status.STABLE, since = "1.3.0")
public <T> @Nullable T get(
final @NonNull String name
) {
@ -246,6 +257,7 @@ public final class FlagContext {
* @return Stored value if present, else {@code null}
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @Nullable T get(
final @NonNull CommandFlag<T> flag
) {

View file

@ -25,6 +25,7 @@ package cloud.commandframework.arguments.parser;
import java.util.Optional;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.common.returnsreceiver.qual.This;
@ -33,6 +34,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
*
* @param <T> Parser return type
*/
@API(status = API.Status.STABLE)
public abstract class ArgumentParseResult<T> {
private ArgumentParseResult() {
@ -75,6 +77,7 @@ public abstract class ArgumentParseResult<T> {
* @return a new result if successful, otherwise a failure
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public abstract <U> @NonNull ArgumentParseResult<U> mapParsedValue(Function<T, U> mapper);
/**
@ -85,6 +88,7 @@ public abstract class ArgumentParseResult<T> {
* @return a new result if successful, otherwise a failure
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public abstract <U> @NonNull ArgumentParseResult<U> flatMapParsedValue(Function<T, ArgumentParseResult<U>> mapper);
/**
@ -101,6 +105,7 @@ public abstract class ArgumentParseResult<T> {
* @return if this is a failure, a transformed result, otherwise this
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public abstract @NonNull ArgumentParseResult<T> mapFailure(Function<Throwable, Throwable> mapper);
@ -160,13 +165,13 @@ public abstract class ArgumentParseResult<T> {
@Override
@SuppressWarnings("unchecked")
public @NonNull <U> ArgumentParseResult<U> mapParsedValue(final Function<T, U> mapper) {
public @NonNull <U> @This ArgumentParseResult<U> mapParsedValue(final Function<T, U> mapper) {
return (ArgumentParseResult<U>) this;
}
@Override
@SuppressWarnings("unchecked")
public @NonNull <U> ArgumentParseResult<U> flatMapParsedValue(final Function<T, ArgumentParseResult<U>> mapper) {
public @NonNull <U> @This ArgumentParseResult<U> flatMapParsedValue(final Function<T, ArgumentParseResult<U>> mapper) {
return (ArgumentParseResult<U>) this;
}

View file

@ -28,6 +28,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import static java.util.Objects.requireNonNull;
@ -39,6 +40,7 @@ import static java.util.Objects.requireNonNull;
* @param <T> Value type
*/
@FunctionalInterface
@API(status = API.Status.STABLE)
public interface ArgumentParser<C, T> {
/**
@ -99,12 +101,13 @@ public interface ArgumentParser<C, T> {
* @return a derived parser.
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
default <O> @NonNull ArgumentParser<C, O> map(final BiFunction<CommandContext<C>, T, ArgumentParseResult<O>> mapper) {
return new MappedArgumentParser<>(this, requireNonNull(mapper, "mapper"));
}
/**
* Check whether or not this argument parser is context free. A context free
* Check whether this argument parser is context free. A context free
* parser will not use the provided command context, and so supports impromptu parsing
*
* @return {@code true} if the parser is context free, else {@code false}
@ -120,6 +123,7 @@ public interface ArgumentParser<C, T> {
* @return The number of arguments tha the parser expects
* @since 1.1.0
*/
@API(status = API.Status.STABLE, since = "1.1.0")
default int getRequestedArgumentCount() {
return DEFAULT_ARGUMENT_COUNT;
}

View file

@ -27,6 +27,7 @@ import cloud.commandframework.context.CommandContext;
import java.util.List;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -38,6 +39,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <O> mapped output type
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public final class MappedArgumentParser<C, I, O> implements ArgumentParser<C, O> {
private final ArgumentParser<C, I> base;
private final BiFunction<CommandContext<C>, I, ArgumentParseResult<O>> mapper;

View file

@ -25,6 +25,7 @@ package cloud.commandframework.arguments.parser;
import io.leangen.geantyref.TypeToken;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <T> Type required by the parameter
*/
@API(status = API.Status.STABLE)
public class ParserParameter<T> {
private final String key;

View file

@ -26,11 +26,13 @@ package cloud.commandframework.arguments.parser;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Collection of {@link ParserParameter parameter}-{@link Object object} pairs
*/
@API(status = API.Status.STABLE)
public final class ParserParameters {
private final Map<ParserParameter<?>, Object> internalMap = new HashMap<>();

View file

@ -31,6 +31,7 @@ import java.util.List;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -40,6 +41,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface ParserRegistry<C> {
/**
@ -130,6 +132,7 @@ public interface ParserRegistry<C> {
* @see #getSuggestionProvider(String) Get a suggestion provider
* @since 1.1.0
*/
@API(status = API.Status.STABLE, since = "1.1.0")
void registerSuggestionProvider(
@NonNull String name,
@NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider
@ -144,6 +147,7 @@ public interface ParserRegistry<C> {
* @see #registerSuggestionProvider(String, BiFunction) Register a suggestion provider
* @since 1.1.0
*/
@API(status = API.Status.STABLE, since = "1.1.0")
@NonNull Optional<BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>>> getSuggestionProvider(
@NonNull String name
);

View file

@ -24,11 +24,13 @@
package cloud.commandframework.arguments.parser;
import io.leangen.geantyref.TypeToken;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Common parser parameters used when resolving types in the {@link ParserRegistry}
*/
@API(status = API.Status.STABLE)
public final class StandardParameters {
/**
@ -65,6 +67,7 @@ public final class StandardParameters {
* @since 1.7.0
* @see cloud.commandframework.annotations.specifier.FlagYielding
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static final ParserParameter<Boolean> FLAG_YIELDING = create(
"flag_yielding",
TypeToken.get(Boolean.class)
@ -74,12 +77,14 @@ public final class StandardParameters {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final ParserParameter<Boolean> QUOTED = create("quoted", TypeToken.get(Boolean.class));
/**
* Indicates that a boolean argument should be liberal.
*
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public static final ParserParameter<Boolean> LIBERAL = create("liberal", TypeToken.get(Boolean.class));
private StandardParameters() {

View file

@ -56,6 +56,7 @@ import java.util.Optional;
import java.util.UUID;
import java.util.function.BiFunction;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -64,6 +65,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <C> Command sender type
*/
@SuppressWarnings({"unused", "unchecked", "rawtypes"})
@API(status = API.Status.STABLE)
public final class StandardParserRegistry<C> implements ParserRegistry<C> {
@SuppressWarnings({"DoubleBraceInitialization"})

View file

@ -33,6 +33,7 @@ import java.util.Queue;
import java.util.function.BiFunction;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -41,6 +42,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <C> Command sender type
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandContext<C>, @NonNull Queue<@NonNull String>,
@NonNull ArgumentParseResult<Boolean>> {
@ -113,6 +115,7 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
* Exception thrown when input fails regex matching in {@link RegexPreprocessor}
*/
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public static final class RegexValidationException extends IllegalArgumentException {
private static final long serialVersionUID = 747826566058072233L;

View file

@ -37,11 +37,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
private final boolean liberal;
@ -116,6 +118,8 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
return this.liberal;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Boolean> {
private boolean liberal = false;
@ -154,6 +158,8 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
}
@API(status = API.Status.STABLE)
public static final class BooleanParser<C> implements ArgumentParser<C, Boolean> {
private static final List<String> LIBERAL = Arrays.asList("TRUE", "YES", "ON", "FALSE", "NO", "OFF");
@ -236,6 +242,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
/**
* Boolean parse exception
*/
@API(status = API.Status.STABLE)
public static final class BooleanParseException extends ParserException {
private static final long serialVersionUID = -2688852086944850025L;

View file

@ -34,11 +34,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class ByteArgument<C> extends CommandArgument<C, Byte> {
private final byte min;
@ -125,6 +127,8 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Byte> {
private byte min = ByteParser.DEFAULT_MINIMUM;
@ -164,6 +168,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final byte defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Byte.toString(defaultValue));
}
@ -182,6 +187,8 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
}
@API(status = API.Status.STABLE)
public static final class ByteParser<C> implements ArgumentParser<C, Byte> {
/**
@ -189,6 +196,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final byte DEFAULT_MINIMUM = Byte.MIN_VALUE;
/**
@ -196,6 +204,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final byte DEFAULT_MAXIMUM = Byte.MAX_VALUE;
private final byte min;
@ -271,6 +280,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMax() {
return this.max != DEFAULT_MAXIMUM;
}
@ -282,6 +292,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMin() {
return this.min != DEFAULT_MINIMUM;
}
@ -309,6 +320,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
* @deprecated use {@link #ByteParseException(String, ByteParser, CommandContext)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.5.0")
public ByteParseException(
final @NonNull String input,
final byte min,
@ -326,6 +338,7 @@ public final class ByteArgument<C> extends CommandArgument<C, Byte> {
* @param context command context
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public ByteParseException(
final @NonNull String input,
final @NonNull ByteParser<?> parser,

View file

@ -36,10 +36,12 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class CharArgument<C> extends CommandArgument<C, Character> {
private CharArgument(
@ -102,6 +104,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Character> {
private Builder(final @NonNull String name) {
@ -123,6 +126,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
}
@API(status = API.Status.STABLE)
public static final class CharacterParser<C> implements ArgumentParser<C, Character> {
@Override
@ -157,6 +161,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
/**
* Char parse exception
*/
@API(status = API.Status.STABLE)
public static final class CharParseException extends ParserException {
private static final long serialVersionUID = 6458851071584278854L;

View file

@ -34,11 +34,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class DoubleArgument<C> extends CommandArgument<C, Double> {
private final double min;
@ -125,6 +127,8 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Double> {
private double min = DoubleParser.DEFAULT_MINIMUM;
@ -164,6 +168,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final double defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Double.toString(defaultValue));
}
@ -182,6 +187,8 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
}
@API(status = API.Status.STABLE)
public static final class DoubleParser<C> implements ArgumentParser<C, Double> {
/**
@ -189,6 +196,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final double DEFAULT_MINIMUM = Double.NEGATIVE_INFINITY;
/**
@ -196,6 +204,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final double DEFAULT_MAXIMUM = Double.POSITIVE_INFINITY;
private final double min;
@ -282,6 +291,7 @@ public final class DoubleArgument<C> extends CommandArgument<C, Double> {
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public static final class DoubleParseException extends NumberParseException {
private static final long serialVersionUID = 1764554911581976586L;

View file

@ -43,6 +43,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -52,6 +53,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <C> sender type
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public final class DurationArgument<C> extends CommandArgument<C, Duration> {
/**
@ -153,6 +155,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
* @param <C> sender type
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static final class Builder<C> extends TypedBuilder<C, Duration, Builder<C>> {
private Builder(final @NonNull String name) {
@ -197,6 +200,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
* @param <C> sender type
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static final class Parser<C> implements ArgumentParser<C, Duration> {
@Override
@ -281,6 +285,7 @@ public final class DurationArgument<C> extends CommandArgument<C, Duration> {
*
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static final class DurationParseException extends ParserException {
private static final long serialVersionUID = 7632293268451349508L;

View file

@ -38,6 +38,7 @@ import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -48,6 +49,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <E> Enum type
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
protected EnumArgument(
@ -129,6 +131,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
}
@API(status = API.Status.STABLE)
public static final class Builder<C, E extends Enum<E>> extends CommandArgument.Builder<C, E> {
private final Class<E> enumClass;
@ -148,6 +151,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
}
@API(status = API.Status.STABLE)
public static final class EnumParser<C, E extends Enum<E>> implements ArgumentParser<C, E> {
private final Class<E> enumClass;
@ -202,6 +206,7 @@ public class EnumArgument<C, E extends Enum<E>> extends CommandArgument<C, E> {
}
@API(status = API.Status.STABLE)
public static final class EnumParseException extends ParserException {
private static final long serialVersionUID = 3465389578951428862L;

View file

@ -34,11 +34,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class FloatArgument<C> extends CommandArgument<C, Float> {
private final float min;
@ -125,6 +127,8 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Float> {
private float min = FloatParser.DEFAULT_MINIMUM;
@ -164,6 +168,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final float defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Float.toString(defaultValue));
}
@ -177,6 +182,8 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
}
@API(status = API.Status.STABLE)
public static final class FloatParser<C> implements ArgumentParser<C, Float> {
/**
@ -184,6 +191,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final float DEFAULT_MINIMUM = Float.NEGATIVE_INFINITY;
/**
@ -191,6 +199,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final float DEFAULT_MAXIMUM = Float.POSITIVE_INFINITY;
private final float min;
@ -258,6 +267,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMax() {
return this.max != DEFAULT_MAXIMUM;
}
@ -269,6 +279,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMin() {
return this.min != DEFAULT_MINIMUM;
}
@ -277,6 +288,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public static final class FloatParseException extends NumberParseException {
private static final long serialVersionUID = -1162983846751812292L;
@ -293,6 +305,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
* @deprecated use {@link #FloatParseException(String, FloatParser, CommandContext)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.5.0")
public FloatParseException(
final @NonNull String input,
final float min,
@ -310,6 +323,7 @@ public final class FloatArgument<C> extends CommandArgument<C, Float> {
* @param commandContext command context
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public FloatParseException(
final @NonNull String input,
final @NonNull FloatParser<?> parser,

View file

@ -38,11 +38,13 @@ import java.util.Queue;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
private static final int MAX_SUGGESTIONS_INCREMENT = 10;
@ -137,6 +139,8 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Integer> {
private int min = IntegerParser.DEFAULT_MINIMUM;
@ -176,6 +180,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final int defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Integer.toString(defaultValue));
}
@ -189,6 +194,8 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
}
@API(status = API.Status.STABLE)
public static final class IntegerParser<C> implements ArgumentParser<C, Integer> {
/**
@ -196,6 +203,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final int DEFAULT_MINIMUM = Integer.MIN_VALUE;
/**
@ -203,6 +211,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final int DEFAULT_MAXIMUM = Integer.MAX_VALUE;
private final int min;
@ -340,6 +349,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public static final class IntegerParseException extends NumberParseException {
private static final long serialVersionUID = -6933923056628373853L;
@ -356,6 +366,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
* @deprecated use {@link #IntegerParseException(String, IntegerParser, CommandContext)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.5.0")
public IntegerParseException(
final @NonNull String input,
final int min,
@ -373,6 +384,7 @@ public final class IntegerArgument<C> extends CommandArgument<C, Integer> {
* @param commandContext command context
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public IntegerParseException(
final @NonNull String input,
final @NonNull IntegerParser<?> parser,

View file

@ -34,11 +34,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class LongArgument<C> extends CommandArgument<C, Long> {
private final long min;
@ -125,6 +127,8 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Long> {
private long min = LongParser.DEFAULT_MINIMUM;
@ -164,6 +168,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final long defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Long.toString(defaultValue));
}
@ -177,6 +182,8 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
}
@API(status = API.Status.STABLE)
public static final class LongParser<C> implements ArgumentParser<C, Long> {
/**
@ -184,6 +191,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final long DEFAULT_MINIMUM = Long.MIN_VALUE;
/**
@ -191,6 +199,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final long DEFAULT_MAXIMUM = Long.MAX_VALUE;
private final long min;
@ -253,6 +262,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMax() {
return this.max != DEFAULT_MAXIMUM;
}
@ -264,6 +274,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMin() {
return this.min != DEFAULT_MINIMUM;
}
@ -285,6 +296,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public static final class LongParseException extends NumberParseException {
private static final long serialVersionUID = 4366856282301198232L;
@ -301,6 +313,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
* @deprecated use {@link #LongParseException(String, LongParser, CommandContext)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.5.0")
public LongParseException(
final @NonNull String input,
final long min,
@ -318,6 +331,7 @@ public final class LongArgument<C> extends CommandArgument<C, Long> {
* @param commandContext command context
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public LongParseException(
final @NonNull String input,
final @NonNull LongParser<?> parser,

View file

@ -34,11 +34,13 @@ import java.util.List;
import java.util.Objects;
import java.util.Queue;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE, since = "1.5.0")
public final class ShortArgument<C> extends CommandArgument<C, Short> {
private final short min;
@ -122,6 +124,8 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
return this.max;
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, Short> {
private short min = ShortParser.DEFAULT_MINIMUM;
@ -161,6 +165,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
* @see CommandArgument.Builder#asOptionalWithDefault(String)
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public @NonNull Builder<C> asOptionalWithDefault(final short defaultValue) {
return (Builder<C>) this.asOptionalWithDefault(Short.toString(defaultValue));
}
@ -174,6 +179,8 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
}
@API(status = API.Status.STABLE)
public static final class ShortParser<C> implements ArgumentParser<C, Short> {
/**
@ -181,6 +188,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final short DEFAULT_MINIMUM = Short.MIN_VALUE;
/**
@ -188,6 +196,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
*
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public static final short DEFAULT_MAXIMUM = Short.MAX_VALUE;
private final short min;
@ -263,6 +272,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMax() {
return this.max != DEFAULT_MAXIMUM;
}
@ -274,6 +284,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
* @return whether the parser has a maximum set
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public boolean hasMin() {
return this.min != DEFAULT_MINIMUM;
}
@ -282,6 +293,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
@SuppressWarnings("serial")
@API(status = API.Status.STABLE, since = "1.5.0")
public static final class ShortParseException extends NumberParseException {
private static final long serialVersionUID = -478674263339091032L;
@ -298,6 +310,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
* @deprecated use {@link #ShortParseException(String, ShortParser, CommandContext)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.5.0")
public ShortParseException(
final @NonNull String input,
final short min,
@ -315,6 +328,7 @@ public final class ShortArgument<C> extends CommandArgument<C, Short> {
* @param commandContext command context
* @since 1.5.0
*/
@API(status = API.Status.STABLE, since = "1.5.0")
public ShortParseException(
final @NonNull String input,
final @NonNull ShortParser<?> parser,

View file

@ -40,10 +40,12 @@ import java.util.StringJoiner;
import java.util.function.BiFunction;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.common.returnsreceiver.qual.This;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class StringArgument<C> extends CommandArgument<C, String> {
private static final Pattern QUOTED_DOUBLE = Pattern.compile("\"(?<inner>(?:[^\"\\\\]|\\\\.)*)\"");
@ -174,6 +176,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
* @return Created argument
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static <C> @NonNull CommandArgument<C, String> greedyFlagYielding(final @NonNull String name) {
return of(name, StringMode.GREEDY_FLAG_YIELDING);
}
@ -199,6 +202,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
}
@API(status = API.Status.STABLE)
public enum StringMode {
SINGLE,
QUOTED,
@ -208,10 +212,12 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
*
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
GREEDY_FLAG_YIELDING
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, String> {
private StringMode stringMode = StringMode.SINGLE;
@ -248,6 +254,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
* @return Builder instance
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public @NonNull @This Builder<C> greedyFlagYielding() {
this.stringMode = StringMode.GREEDY_FLAG_YIELDING;
return this;
@ -304,6 +311,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
@SuppressWarnings("UnnecessaryLambda")
@API(status = API.Status.STABLE)
public static final class StringParser<C> implements ArgumentParser<C, String> {
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
@ -461,6 +469,7 @@ public final class StringArgument<C> extends CommandArgument<C, String> {
}
@API(status = API.Status.STABLE)
public static final class StringParseException extends ParserException {
private static final long serialVersionUID = -8903115465005472945L;

View file

@ -34,6 +34,7 @@ import java.util.List;
import java.util.Queue;
import java.util.function.BiFunction;
import java.util.regex.Pattern;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -44,6 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
private StringArrayArgument(
@ -95,6 +97,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
* @return Created argument
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static <C> @NonNull StringArrayArgument<C> of(
final @NonNull String name,
final boolean flagYielding,
@ -140,6 +143,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
* @return Created argument
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public static <C> @NonNull StringArrayArgument<C> optional(
final @NonNull String name,
final boolean flagYielding,
@ -160,6 +164,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class StringArrayParser<C> implements ArgumentParser<C, String[]> {
private static final Pattern FLAG_PATTERN = Pattern.compile("(-[A-Za-z_\\-0-9])|(--[A-Za-z_\\-0-9]*)");
@ -179,6 +184,7 @@ public final class StringArrayArgument<C> extends CommandArgument<C, String[]> {
* @param flagYielding Whether the parser should stop parsing when encountering a potential flag
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
public StringArrayParser(final boolean flagYielding) {
this.flagYielding = flagYielding;
}

View file

@ -37,10 +37,12 @@ import java.util.Objects;
import java.util.Queue;
import java.util.UUID;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
private UUIDArgument(
@ -103,6 +105,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
}
@API(status = API.Status.STABLE)
public static final class Builder<C> extends CommandArgument.Builder<C, UUID> {
private Builder(final @NonNull String name) {
@ -128,6 +131,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
}
@API(status = API.Status.STABLE)
public static final class UUIDParser<C> implements ArgumentParser<C, UUID> {
@Override
@ -160,6 +164,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
}
@API(status = API.Status.STABLE)
public static final class UUIDParseException extends ParserException {
private static final long serialVersionUID = 6399602590976540023L;

View file

@ -24,11 +24,13 @@
package cloud.commandframework.captions;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* This is a reference to a caption and does not contain any message itself
*/
@API(status = API.Status.STABLE)
public final class Caption {
private final String key;

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.captions;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -30,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface CaptionRegistry<C> {
/**

View file

@ -23,11 +23,13 @@
//
package cloud.commandframework.captions;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Key-value pair used to replace variables in captions
*/
@API(status = API.Status.STABLE)
public final class CaptionVariable {
private final String key;

View file

@ -23,11 +23,13 @@
//
package cloud.commandframework.captions;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Utility that replaces variables in captions
*/
@API(status = API.Status.STABLE)
public interface CaptionVariableReplacementHandler {
/**

View file

@ -24,6 +24,7 @@
package cloud.commandframework.captions;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface FactoryDelegatingCaptionRegistry<C> extends CaptionRegistry<C> {
/**

View file

@ -26,6 +26,7 @@ package cloud.commandframework.captions;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public class SimpleCaptionRegistry<C> implements FactoryDelegatingCaptionRegistry<C> {
/**

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.captions;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -30,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class SimpleCaptionRegistryFactory<C> {
/**

View file

@ -23,11 +23,13 @@
//
package cloud.commandframework.captions;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Simple implementation of {@link CaptionVariableReplacementHandler}
*/
@API(status = API.Status.STABLE)
public final class SimpleCaptionVariableReplacementHandler implements CaptionVariableReplacementHandler {
@Override

View file

@ -26,11 +26,13 @@ package cloud.commandframework.captions;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* {@link Caption} instances for messages in cloud-core
*/
@API(status = API.Status.STABLE)
public final class StandardCaptionKeys {
private static final Collection<Caption> RECOGNIZED_CAPTIONS = new LinkedList<>();

View file

@ -42,6 +42,7 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -50,6 +51,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public class CommandContext<C> {
private final CaptionVariableReplacementHandler captionVariableReplacementHandler;
@ -71,6 +73,7 @@ public class CommandContext<C> {
* @deprecated Provide a command manager instead of a caption registry
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
public CommandContext(final @NonNull C commandSender, final @NonNull CaptionRegistry<C> captionRegistry) {
this(false, commandSender, captionRegistry);
}
@ -82,6 +85,7 @@ public class CommandContext<C> {
* @param commandManager Command manager
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public CommandContext(final @NonNull C commandSender, final @NonNull CommandManager<C> commandManager) {
this(false, commandSender, commandManager);
}
@ -89,12 +93,13 @@ public class CommandContext<C> {
/**
* Create a new command context instance
*
* @param suggestions Whether or not the context is created for command suggestions
* @param suggestions Whether the context is created for command suggestions
* @param commandSender Sender of the command
* @param captionRegistry Caption registry
* @deprecated Provide a command manager instead of a caption registry
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
public CommandContext(
final boolean suggestions,
final @NonNull C commandSender,
@ -110,11 +115,12 @@ public class CommandContext<C> {
/**
* Create a new command context instance
*
* @param suggestions Whether or not the context is created for command suggestions
* @param suggestions Whether the context is created for command suggestions
* @param commandSender Sender of the command
* @param commandManager Command manager
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public CommandContext(
final boolean suggestions,
final @NonNull C commandSender,
@ -160,6 +166,7 @@ public class CommandContext<C> {
* @return Command sender
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public boolean hasPermission(final @NonNull CommandPermission permission) {
return this.commandManager.hasPermission(this.commandSender, permission);
}
@ -171,6 +178,7 @@ public class CommandContext<C> {
* @return Command sender
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
public boolean hasPermission(final @NonNull String permission) {
return this.commandManager.hasPermission(this.commandSender, permission);
}
@ -229,6 +237,7 @@ public class CommandContext<C> {
* @param <T> Value type
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> void store(final @NonNull CloudKeyHolder<T> keyHolder, final @NonNull T value) {
this.internalStorage.put(keyHolder.getKey(), value);
}
@ -244,6 +253,7 @@ public class CommandContext<C> {
* @param <T> Value type
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public <T> void set(final @NonNull String key, final @Nullable T value) {
if (value != null) {
this.store(key, value);
@ -263,6 +273,7 @@ public class CommandContext<C> {
* @param <T> Value type
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> void set(final @NonNull CloudKey<T> key, final @Nullable T value) {
if (value != null) {
this.store(key, value);
@ -278,6 +289,7 @@ public class CommandContext<C> {
* @return Whether the context has a value for the provided key
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public boolean contains(final @NonNull String key) {
return this.contains(SimpleCloudKey.of(key));
}
@ -289,6 +301,7 @@ public class CommandContext<C> {
* @return Whether the context has a value for the provided key
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public boolean contains(final @NonNull CloudKey<?> key) {
return this.internalStorage.containsKey(key);
}
@ -299,6 +312,7 @@ public class CommandContext<C> {
* @return An immutable copy of this command context as a map
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public @NonNull Map<@NonNull String, @Nullable ?> asMap() {
final Map<String, Object> values = new HashMap<>();
this.internalStorage.forEach((key, value) -> values.put(key.getName(), value));
@ -332,6 +346,7 @@ public class CommandContext<C> {
* @return Value
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKey<T> key) {
final Object value = this.internalStorage.get(key);
if (value != null) {
@ -365,6 +380,7 @@ public class CommandContext<C> {
* @since 1.4.0
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull Optional<T> getOptional(final @NonNull CloudKeyHolder<T> keyHolder) {
final Object value = this.internalStorage.get(keyHolder.getKey());
if (value != null) {
@ -390,6 +406,7 @@ public class CommandContext<C> {
* @param key Key to remove
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public void remove(final @NonNull CloudKey<?> key) {
this.internalStorage.remove(key);
}
@ -423,6 +440,7 @@ public class CommandContext<C> {
* @since 1.4.0
*/
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull T get(final @NonNull CloudKey<T> key) {
final Object value = this.internalStorage.get(key);
if (value == null) {
@ -454,6 +472,7 @@ public class CommandContext<C> {
* @throws NullPointerException If no such value is stored
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @NonNull T get(final @NonNull CloudKeyHolder<T> keyHolder) {
return this.get(keyHolder.getKey());
}
@ -497,6 +516,7 @@ public class CommandContext<C> {
* @return Argument, or supplied default value
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @Nullable T getOrDefault(
final @NonNull CloudKey<T> key,
final @Nullable T defaultValue
@ -513,6 +533,7 @@ public class CommandContext<C> {
* @return Argument, or supplied default value
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public <T> @Nullable T getOrSupplyDefault(
final @NonNull String key,
final @NonNull Supplier<@Nullable T> defaultSupplier
@ -529,6 +550,7 @@ public class CommandContext<C> {
* @return Argument, or supplied default value
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public <T> @Nullable T getOrSupplyDefault(
final @NonNull CloudKey<T> key,
final @NonNull Supplier<@Nullable T> defaultSupplier
@ -551,6 +573,7 @@ public class CommandContext<C> {
* @return {@link #getRawInput()} joined with {@code " "} as the delimiter
* @since 1.1.0
*/
@API(status = API.Status.STABLE, since = "1.1.0")
public @NonNull String getRawInputJoined() {
return String.join(" ", this.getRawInput());
}
@ -593,6 +616,7 @@ public class CommandContext<C> {
* @return Currently parsing {@link CommandArgument} or {@code null}
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public @Nullable CommandArgument<C, ?> getCurrentArgument() {
return this.currentArgument;
}
@ -605,6 +629,7 @@ public class CommandContext<C> {
* @param argument Currently parsing {@link CommandArgument} or {@code null}
* @since 1.2.0
*/
@API(status = API.Status.STABLE, since = "1.2.0")
public void setCurrentArgument(final @Nullable CommandArgument<C, ?> argument) {
this.currentArgument = argument;
}
@ -618,7 +643,7 @@ public class CommandContext<C> {
* @return Optional that may contain the created value
* @since 1.3.0
*/
@SuppressWarnings("unchecked")
@API(status = API.Status.STABLE, since = "1.3.0")
public <@NonNull T> @NonNull Optional<T> inject(final @NonNull Class<T> clazz) {
if (this.commandManager == null) {
throw new UnsupportedOperationException(
@ -636,6 +661,7 @@ public class CommandContext<C> {
* <p>
* The times are measured in nanoseconds.
*/
@API(status = API.Status.STABLE)
public static final class ArgumentTiming {
private long start;
@ -647,7 +673,7 @@ public class CommandContext<C> {
*
* @param start Start time (in nanoseconds)
* @param end End time (in nanoseconds)
* @param success Whether or not the argument was parsed successfully
* @param success Whether the argument was parsed successfully
*/
public ArgumentTiming(final long start, final long end, final boolean success) {
this.start = start;
@ -690,7 +716,7 @@ public class CommandContext<C> {
* Set the end time
*
* @param end End time (in nanoseconds)
* @param success Whether or not the argument was parsed successfully
* @param success Whether the argument was parsed successfully
*/
public void setEnd(final long end, final boolean success) {
this.end = end;
@ -707,7 +733,7 @@ public class CommandContext<C> {
}
/**
* Check whether or not the value was parsed successfully
* Check whether the value was parsed successfully
*
* @return {@code true} if the value was parsed successfully, {@code false} if not
*/

View file

@ -25,6 +25,7 @@ package cloud.commandframework.context;
import cloud.commandframework.CommandManager;
import cloud.commandframework.captions.CaptionRegistry;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender
*/
@API(status = API.Status.STABLE)
public interface CommandContextFactory<C> {
/**
@ -44,6 +46,7 @@ public interface CommandContextFactory<C> {
* @deprecated Provide a command manager instead of a caption registry
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
@NonNull CommandContext<C> create(
boolean suggestions,
@NonNull C sender,
@ -59,6 +62,7 @@ public interface CommandContextFactory<C> {
* @return Command context
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
@NonNull CommandContext<C> create(
boolean suggestions,
@NonNull C sender,

View file

@ -25,9 +25,11 @@ package cloud.commandframework.context;
import cloud.commandframework.CommandManager;
import cloud.commandframework.captions.CaptionRegistry;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
@SuppressWarnings("deprecation")
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class StandardCommandContextFactory<C> implements CommandContextFactory<C> {
@Override

View file

@ -28,6 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.context.CommandContext;
import java.util.Iterator;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -37,6 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* is detected.
*/
@SuppressWarnings({"unused", "serial"})
@API(status = API.Status.STABLE)
public final class AmbiguousNodeException extends IllegalStateException {
private static final long serialVersionUID = -200207173805584709L;
@ -51,6 +53,7 @@ public final class AmbiguousNodeException extends IllegalStateException {
* @param ambiguousNode Node that caused exception
* @param children All children of the parent
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public AmbiguousNodeException(
final @Nullable CommandArgument<?, ?> parentNode,
final @NonNull CommandArgument<?, ?> ambiguousNode,

View file

@ -25,8 +25,10 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.arguments.CommandArgument;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
@API(status = API.Status.STABLE)
public class ArgumentParseException extends CommandParseException {
private static final long serialVersionUID = -4385446899439587461L;
@ -39,6 +41,7 @@ public class ArgumentParseException extends CommandParseException {
* @param commandSender Command sender
* @param currentChain Chain leading up to the exception
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public ArgumentParseException(
final @NonNull Throwable throwable,
final @NonNull Object commandSender,

View file

@ -24,6 +24,7 @@
package cloud.commandframework.exceptions;
import cloud.commandframework.context.CommandContext;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @since 1.2.0
*/
@SuppressWarnings("serial")
@API(status = API.Status.STABLE, since = "1.2.0")
public class CommandExecutionException extends IllegalArgumentException {
private static final long serialVersionUID = -4785446899438294661L;
@ -43,6 +45,7 @@ public class CommandExecutionException extends IllegalArgumentException {
*
* @param cause Exception thrown during the execution of a command handler
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public CommandExecutionException(final @NonNull Throwable cause) {
this(cause, null);
}
@ -54,6 +57,7 @@ public class CommandExecutionException extends IllegalArgumentException {
* @param commandContext Command context
* @since 1.4.0
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.4.0")
public CommandExecutionException(final @NonNull Throwable cause, final @Nullable CommandContext<?> commandContext) {
super(cause);
this.commandContext = commandContext;
@ -65,6 +69,7 @@ public class CommandExecutionException extends IllegalArgumentException {
* @return Command
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @Nullable CommandContext<?> getCommandContext() {
return this.commandContext;
}

View file

@ -26,12 +26,14 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.arguments.CommandArgument;
import java.util.Collections;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Exception thrown when parsing user input into a command
*/
@SuppressWarnings({"unused", "serial"})
@API(status = API.Status.STABLE)
public class CommandParseException extends IllegalArgumentException {
private static final long serialVersionUID = -2415981126382517435L;
@ -44,6 +46,7 @@ public class CommandParseException extends IllegalArgumentException {
* @param commandSender Sender who executed the command
* @param currentChain Chain leading up to the exception
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
protected CommandParseException(
final @NonNull Object commandSender,
final @NonNull List<CommandArgument<?, ?>> currentChain

View file

@ -26,6 +26,7 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.Command;
import cloud.commandframework.arguments.CommandArgument;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Exception thrown when an invalid command sender tries to execute a command
*/
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public final class InvalidCommandSenderException extends CommandParseException {
private static final long serialVersionUID = 7372142477529875598L;
@ -46,6 +48,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
* @param requiredSender The sender type that is required
* @param currentChain Chain leading up to the exception
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public InvalidCommandSenderException(
final @NonNull Object commandSender,
final @NonNull Class<?> requiredSender,
@ -63,6 +66,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
* @param command Command
* @since 1.4.0
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.4.0")
public InvalidCommandSenderException(
final @NonNull Object commandSender,
final @NonNull Class<?> requiredSender,
@ -98,6 +102,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
* @return Command
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @Nullable Command<?> getCommand() {
return this.command;
}

View file

@ -25,12 +25,14 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.arguments.CommandArgument;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Exception sent when a command sender inputs invalid command syntax
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public class InvalidSyntaxException extends CommandParseException {
private static final long serialVersionUID = -4183356059293785202L;
@ -43,6 +45,7 @@ public class InvalidSyntaxException extends CommandParseException {
* @param commandSender Sender that sent the command
* @param currentChain Chain leading up to issue
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public InvalidSyntaxException(
final @NonNull String correctSyntax,
final @NonNull Object commandSender,

View file

@ -25,6 +25,7 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.Command;
import cloud.commandframework.arguments.CommandArgument;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* that is registered as a leaf node, does not contain an owning {@link Command}
*/
@SuppressWarnings({"unused", "serial"})
@API(status = API.Status.STABLE)
public final class NoCommandInLeafException extends IllegalStateException {
private static final long serialVersionUID = 3373529875213310821L;
@ -42,6 +44,7 @@ public final class NoCommandInLeafException extends IllegalStateException {
*
* @param commandArgument Command argument that caused the exception
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public NoCommandInLeafException(final @NonNull CommandArgument<?, ?> commandArgument) {
super(String.format("Leaf node '%s' does not have associated owning command", commandArgument.getName()));
this.commandArgument = commandArgument;

View file

@ -27,6 +27,7 @@ import cloud.commandframework.Command;
import cloud.commandframework.arguments.CommandArgument;
import cloud.commandframework.permission.CommandPermission;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -34,6 +35,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* to execute a {@link Command}
*/
@SuppressWarnings({"unused", "serial"})
@API(status = API.Status.STABLE)
public class NoPermissionException extends CommandParseException {
private static final long serialVersionUID = 7103413337750692843L;
@ -46,6 +48,7 @@ public class NoPermissionException extends CommandParseException {
* @param commandSender Command sender
* @param currentChain Chain leading up to the exception
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public NoPermissionException(
final @NonNull CommandPermission missingPermission,
final @NonNull Object commandSender,

View file

@ -25,6 +25,7 @@ package cloud.commandframework.exceptions;
import cloud.commandframework.arguments.CommandArgument;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* a command that doesn't exist
*/
@SuppressWarnings("unused")
@API(status = API.Status.STABLE)
public final class NoSuchCommandException extends CommandParseException {
private static final long serialVersionUID = -7775865652882764771L;
@ -44,6 +46,7 @@ public final class NoSuchCommandException extends CommandParseException {
* @param currentChain Chain leading up to the exception
* @param command Entered command (following the command chain)
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public NoSuchCommandException(
final @NonNull Object commandSender,
final @NonNull List<CommandArgument<?, ?>> currentChain,

View file

@ -25,6 +25,7 @@ package cloud.commandframework.exceptions.parsing;
import cloud.commandframework.captions.StandardCaptionKeys;
import cloud.commandframework.context.CommandContext;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @since 1.1.0
*/
@API(status = API.Status.STABLE, since = "1.1.0")
public class NoInputProvidedException extends ParserException {
private static final long serialVersionUID = 3485754951593709559L;

View file

@ -26,8 +26,10 @@ package cloud.commandframework.exceptions.parsing;
import cloud.commandframework.captions.CaptionVariable;
import cloud.commandframework.captions.StandardCaptionKeys;
import cloud.commandframework.context.CommandContext;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
@API(status = API.Status.STABLE)
public abstract class NumberParseException extends ParserException {
private static final long serialVersionUID = 3018775374056029797L;

View file

@ -27,9 +27,11 @@ import cloud.commandframework.captions.Caption;
import cloud.commandframework.captions.CaptionVariable;
import cloud.commandframework.context.CommandContext;
import java.util.Arrays;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
@SuppressWarnings("serial")
@API(status = API.Status.STABLE)
public class ParserException extends IllegalArgumentException {
private static final long serialVersionUID = -4409795575435072170L;
@ -64,6 +66,7 @@ public class ParserException extends IllegalArgumentException {
* @return The caption
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull Caption errorCaption() {
return this.errorCaption;
}
@ -75,6 +78,7 @@ public class ParserException extends IllegalArgumentException {
* @return The caption variables
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public @NonNull CaptionVariable @NonNull [] captionVariables() {
return Arrays.copyOf(this.captionVariables, this.captionVariables.length);
}

View file

@ -36,6 +36,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Consumer;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.common.returnsreceiver.qual.This;
@ -45,6 +46,7 @@ import org.checkerframework.common.returnsreceiver.qual.This;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class AsynchronousCommandExecutionCoordinator<C> extends CommandExecutionCoordinator<C> {
private final CommandManager<C> commandManager;
@ -128,6 +130,7 @@ public final class AsynchronousCommandExecutionCoordinator<C> extends CommandExe
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public static final class Builder<C> {
private Executor executor = null;

View file

@ -33,6 +33,7 @@ import java.util.Objects;
import java.util.Queue;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -44,6 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public abstract class CommandExecutionCoordinator<C> {
private final CommandTree<C> commandTree;
@ -95,6 +97,7 @@ public abstract class CommandExecutionCoordinator<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public static final class SimpleCoordinator<C> extends
CommandExecutionCoordinator<C> {

View file

@ -28,6 +28,7 @@ import cloud.commandframework.context.CommandContext;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -39,6 +40,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @param <C> Command sender type
*/
@FunctionalInterface
@API(status = API.Status.STABLE)
public interface CommandExecutionHandler<C> {
/**
@ -48,6 +50,7 @@ public interface CommandExecutionHandler<C> {
* @return command execution handler that does nothing
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
static <C> @NonNull CommandExecutionHandler<C> noOpCommandExecutionHandler() {
return new NullCommandExecutionHandler<>();
}
@ -64,6 +67,7 @@ public interface CommandExecutionHandler<C> {
* @return multicast-delegate command execution handler
* @since 1.7.0
*/
@API(status = API.Status.STABLE, since = "1.7.0")
static <C> @NonNull CommandExecutionHandler<C> delegatingExecutionHandler(
final List<CommandExecutionHandler<C>> handlers
) {
@ -84,6 +88,7 @@ public interface CommandExecutionHandler<C> {
* @return future that completes when the command has finished execution
* @since 1.6.0
*/
@API(status = API.Status.STABLE, since = "1.6.0")
default CompletableFuture<@Nullable Void> executeFuture(@NonNull CommandContext<C> commandContext) {
final CompletableFuture<Void> future = new CompletableFuture<>();
try {
@ -101,6 +106,7 @@ public interface CommandExecutionHandler<C> {
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
class NullCommandExecutionHandler<C> implements CommandExecutionHandler<C> {
@Override
@ -117,6 +123,7 @@ public interface CommandExecutionHandler<C> {
* @since 1.6.0
*/
@FunctionalInterface
@API(status = API.Status.STABLE, since = "1.6.0")
interface FutureCommandExecutionHandler<C> extends CommandExecutionHandler<C> {
@Override
@ -140,6 +147,7 @@ public interface CommandExecutionHandler<C> {
* @see #delegatingExecutionHandler(List)
* @since 1.7.0
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*", since = "1.7.0")
final class MulticastDelegateFutureCommandExecutionHandler<C> implements FutureCommandExecutionHandler<C> {
private final List<CommandExecutionHandler<C>> handlers;

View file

@ -24,6 +24,7 @@
package cloud.commandframework.execution;
import cloud.commandframework.context.CommandContext;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public class CommandResult<C> {
private final CommandContext<C> commandContext;

View file

@ -26,6 +26,7 @@ package cloud.commandframework.execution;
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
import java.util.List;
import java.util.function.BiFunction;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface CommandSuggestionProcessor<C> extends
BiFunction<@NonNull CommandPreprocessingContext<C>, @NonNull List<String>, @NonNull List<String>> {

View file

@ -26,13 +26,15 @@ package cloud.commandframework.execution;
import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext;
import java.util.LinkedList;
import java.util.List;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Command suggestions processor that checks the input queue head and filters based on that
* Command suggestion processor that checks the input queue head and filters based on that
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class FilteringCommandSuggestionProcessor<C> implements CommandSuggestionProcessor<C> {
@Override

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.execution.postprocessor;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class AcceptingCommandPostprocessor<C> implements CommandPostprocessor<C> {
/**

View file

@ -26,6 +26,7 @@ package cloud.commandframework.execution.postprocessor;
import cloud.commandframework.Command;
import cloud.commandframework.context.CommandContext;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class CommandPostprocessingContext<C> {
private final CommandContext<@NonNull C> commandContext;

View file

@ -24,12 +24,14 @@
package cloud.commandframework.execution.postprocessor;
import cloud.commandframework.services.types.ConsumerService;
import org.apiguardian.api.API;
/**
* Command postprocessor that acts on commands before execution
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface CommandPostprocessor<C> extends ConsumerService<CommandPostprocessingContext<C>> {
}

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.execution.preprocessor;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -31,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class AcceptingCommandPreprocessor<C> implements CommandPreprocessor<C> {
/**

View file

@ -26,6 +26,7 @@ package cloud.commandframework.execution.preprocessor;
import cloud.commandframework.context.CommandContext;
import java.util.LinkedList;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -33,6 +34,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public final class CommandPreprocessingContext<C> {
private final CommandContext<C> commandContext;

View file

@ -24,6 +24,7 @@
package cloud.commandframework.execution.preprocessor;
import cloud.commandframework.services.types.ConsumerService;
import org.apiguardian.api.API;
/**
* Command preprocessor that gets to act on command input
@ -34,6 +35,7 @@ import cloud.commandframework.services.types.ConsumerService;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public interface CommandPreprocessor<C> extends ConsumerService<CommandPreprocessingContext<C>> {
}

View file

@ -37,6 +37,7 @@ import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -51,6 +52,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* @param <C> Command sender type
*/
@API(status = API.Status.STABLE)
public class CommandConfirmationManager<C> {
/**
@ -67,10 +69,11 @@ public class CommandConfirmationManager<C> {
);
/**
* Meta data stored for commands that require confirmation
* Metadata stored for commands that require confirmation
*
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public static final CommandMeta.Key<Boolean> META_CONFIRMATION_REQUIRED = CommandMeta.Key.of(
Boolean.class,
"cloud:require_confirmation",

View file

@ -25,6 +25,7 @@ package cloud.commandframework.internal;
import java.util.LinkedList;
import java.util.StringTokenizer;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* at every blank space. If the input string ends with a blank space, a trailing
* empty string will be added to the token list
*/
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
public final class CommandInputTokenizer {
private static final String DELIMITER = " ";

View file

@ -24,6 +24,7 @@
package cloud.commandframework.internal;
import cloud.commandframework.Command;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* the target platform does not have its own concept of commands
*/
@FunctionalInterface
@API(status = API.Status.STABLE)
public interface CommandRegistrationHandler {
/**
@ -52,6 +54,8 @@ public interface CommandRegistrationHandler {
*/
boolean registerCommand(@NonNull Command<?> command);
@API(status = API.Status.INTERNAL, consumers = "cloud.commandframework.*")
final class NullCommandRegistrationHandler implements CommandRegistrationHandler {
private NullCommandRegistrationHandler() {

View file

@ -24,6 +24,7 @@
package cloud.commandframework.keys;
import io.leangen.geantyref.TypeToken;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <T> The type of the key
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public interface CloudKey<T> {
/**

View file

@ -23,6 +23,7 @@
//
package cloud.commandframework.keys;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -32,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @since 1.4.0
*/
@FunctionalInterface
@API(status = API.Status.STABLE, since = "1.4.0")
public interface CloudKeyHolder<T> {
/**

View file

@ -25,6 +25,7 @@ package cloud.commandframework.keys;
import io.leangen.geantyref.TypeToken;
import java.util.Objects;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -35,6 +36,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* @param <T> Key type
* @since 1.4.0
*/
@API(status = API.Status.STABLE, since = "1.4.0")
public final class SimpleCloudKey<@NonNull T> implements CloudKey<T> {
private final String name;

View file

@ -30,6 +30,7 @@ import io.leangen.geantyref.TypeToken;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import org.apiguardian.api.API;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -41,6 +42,7 @@ import static java.util.Objects.requireNonNull;
* <p>
* Appropriate use for command meta would be fixed state, such as command descriptions.
*/
@API(status = API.Status.STABLE)
public abstract class CommandMeta {
private static final Key<String> LEGACY_HIDDEN = Key.of(String.class, "hidden");
@ -74,6 +76,7 @@ public abstract class CommandMeta {
* @deprecated for removal since 1.3.0, see typesafe variant at {@link #get(Key)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
public abstract @NonNull Optional<String> getValue(@NonNull String key);
/**
@ -85,6 +88,7 @@ public abstract class CommandMeta {
* @deprecated for removal since 1.3.0, see typesafe variant at {@link #getOrDefault(Key, Object)} instead
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
public abstract @NonNull String getOrDefault(@NonNull String key, @NonNull String defaultValue);
/**
@ -95,6 +99,7 @@ public abstract class CommandMeta {
* @return Optional that may contain the associated value
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public abstract <V> @NonNull Optional<V> get(@NonNull Key<V> key);
/**
@ -106,6 +111,7 @@ public abstract class CommandMeta {
* @return Value, or default value
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public abstract <V> @NonNull V getOrDefault(@NonNull Key<V> key, @NonNull V defaultValue);
/**
@ -115,6 +121,7 @@ public abstract class CommandMeta {
* @deprecated for removal since 1.3.0, use {@link #getAllValues()} instead.
*/
@Deprecated
@API(status = API.Status.DEPRECATED, since = "1.3.0")
public abstract @NonNull Map<@NonNull String, @NonNull String> getAll();
/**
@ -123,14 +130,17 @@ public abstract class CommandMeta {
* @return Copy of meta map
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public abstract @NonNull Map<@NonNull String, @NonNull ?> getAllValues();
/**
* A key into the metadata map.
*
* @param <V> value type
* @since 1.3.0
*/
@API(status = API.Status.STABLE, since = "1.3.0")
public interface Key<V> extends CloudKey<V> {
/**

Some files were not shown because too many files have changed in this diff Show more