chore(core): deprecate prefixed accessors/mutators in CommandManager (#377)

chore(core): deprecate prefixed accessors/mutators in CommandManager.java

All prefixed (actual) getters/setters in CommandManager have been deprecated, and non-prefixed alternatives have been introduced. I've also put some effort into improving the JavaDocs of these methods.
This commit is contained in:
Alexander Söderberg 2022-06-13 10:57:12 +02:00 committed by Jason
parent 687cd4c536
commit 296539d56c
48 changed files with 400 additions and 157 deletions

View file

@ -439,7 +439,7 @@ public final class AnnotationParser<C> {
));
}
try {
this.manager.getParserRegistry().registerSuggestionProvider(
this.manager.parserRegistry().registerSuggestionProvider(
this.processString(suggestions.value()),
new MethodSuggestionsProvider<>(instance, method)
);
@ -476,7 +476,7 @@ public final class AnnotationParser<C> {
if (suggestions.isEmpty()) {
suggestionsProvider = (context, input) -> Collections.emptyList();
} else {
suggestionsProvider = this.manager.getParserRegistry().getSuggestionProvider(suggestions)
suggestionsProvider = this.manager.parserRegistry().getSuggestionProvider(suggestions)
.orElseThrow(() -> new NullPointerException(
String.format(
"Cannot find the suggestions provider with name '%s'",
@ -493,12 +493,12 @@ public final class AnnotationParser<C> {
parameters -> methodArgumentParser;
final String name = this.processString(parser.name());
if (name.isEmpty()) {
this.manager.getParserRegistry().registerParserSupplier(
this.manager.parserRegistry().registerParserSupplier(
TypeToken.get(method.getGenericReturnType()),
parserFunction
);
} else {
this.manager.getParserRegistry().registerNamedParserSupplier(
this.manager.parserRegistry().registerNamedParserSupplier(
name,
parserFunction
);
@ -687,12 +687,12 @@ public final class AnnotationParser<C> {
final Parameter parameter = argumentPair.getParameter();
final Collection<Annotation> annotations = Arrays.asList(parameter.getAnnotations());
final TypeToken<?> token = TypeToken.get(parameter.getParameterizedType());
final ParserParameters parameters = this.manager.getParserRegistry()
final ParserParameters parameters = this.manager.parserRegistry()
.parseAnnotations(token, annotations);
/* Create the argument parser */
final ArgumentParser<C, ?> parser;
if (argumentPair.getArgument().parserName().isEmpty()) {
parser = this.manager.getParserRegistry()
parser = this.manager.parserRegistry()
.createParser(token, parameters)
.orElseThrow(() -> new IllegalArgumentException(
String.format("Parameter '%s' in method '%s' "
@ -702,7 +702,7 @@ public final class AnnotationParser<C> {
token.getType().getTypeName()
)));
} else {
parser = this.manager.getParserRegistry()
parser = this.manager.parserRegistry()
.createParser(argumentPair.getArgument().parserName(), parameters)
.orElseThrow(() -> new IllegalArgumentException(
String.format("Parameter '%s' in method '%s' "
@ -745,7 +745,7 @@ public final class AnnotationParser<C> {
} else if (!argument.suggestions().isEmpty()) { /* Check whether or not a suggestion provider should be set */
final String suggestionProviderName = argument.suggestions();
final Optional<BiFunction<CommandContext<C>, String, List<String>>> suggestionsFunction =
this.manager.getParserRegistry().getSuggestionProvider(suggestionProviderName);
this.manager.parserRegistry().getSuggestionProvider(suggestionProviderName);
argumentBuilder.withSuggestionsProvider(
suggestionsFunction.orElseThrow(() ->
new IllegalArgumentException(String.format(

View file

@ -65,7 +65,7 @@ public @interface Argument {
* <p>
* For this to work, the suggestion needs to be registered in the parser registry. To do this, use
* {@link cloud.commandframework.arguments.parser.ParserRegistry#registerSuggestionProvider(String, BiFunction)}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#getParserRegistry()}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#parserRegistry()}.
*
* @return The name of the suggestion provider, or {@code ""} if the default suggestion provider for the argument parser
* should be used instead

View file

@ -72,7 +72,7 @@ public @interface Flag {
* <p>
* For this to work, the suggestion needs to be registered in the parser registry. To do this, use
* {@link cloud.commandframework.arguments.parser.ParserRegistry#registerSuggestionProvider(String, BiFunction)}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#getParserRegistry()}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#parserRegistry()}.
*
* @return The name of the suggestion provider, or {@code ""} if the default suggestion provider for the argument parser
* should be used instead

View file

@ -75,7 +75,7 @@ final class FlagExtractor implements Function<@NonNull Method, Collection<@NonNu
} else {
final TypeToken<?> token = TypeToken.get(parameter.getType());
final Collection<Annotation> annotations = Arrays.asList(parameter.getAnnotations());
final ParserRegistry<?> registry = this.commandManager.getParserRegistry();
final ParserRegistry<?> registry = this.commandManager.parserRegistry();
final ArgumentParser<?, ?> parser;
final String parserName = this.annotationParser.processString(flag.parserName());
if (parserName.isEmpty()) {

View file

@ -61,7 +61,7 @@ public @interface Parser {
* <p>
* For this to work, the suggestion needs to be registered in the parser registry. To do this, use
* {@link cloud.commandframework.arguments.parser.ParserRegistry#registerSuggestionProvider(String, BiFunction)}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#getParserRegistry()}.
* The registry instance can be retrieved using {@link cloud.commandframework.CommandManager#parserRegistry()}.
*
* @return The name of the suggestion provider, or {@code ""}
*/