Skip to content

Commit 5ce1a86

Browse files
authored
chore: clean up CommandMeta (#548)
1 parent fb7bd3d commit 5ce1a86

46 files changed

Lines changed: 184 additions & 541 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cloud-annotations/src/main/java/cloud/commandframework/annotations/AnnotationParser.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import cloud.commandframework.execution.CommandExecutionHandler;
4848
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
4949
import cloud.commandframework.meta.CommandMeta;
50-
import cloud.commandframework.meta.SimpleCommandMeta;
50+
import cloud.commandframework.meta.CommandMetaBuilder;
5151
import cloud.commandframework.types.tuples.Pair;
5252
import io.leangen.geantyref.GenericTypeReflector;
5353
import io.leangen.geantyref.TypeToken;
@@ -139,7 +139,20 @@ public AnnotationParser(
139139
final @NonNull CommandManager<C> manager,
140140
final @NonNull Class<C> commandSenderClass
141141
) {
142-
this(manager, TypeToken.get(commandSenderClass), parameters -> SimpleCommandMeta.empty());
142+
this(manager, TypeToken.get(commandSenderClass), parameters -> CommandMeta.empty());
143+
}
144+
145+
/**
146+
* Construct a new annotation parser
147+
*
148+
* @param manager Command manager instance
149+
* @param commandSenderClass Command sender class
150+
*/
151+
public AnnotationParser(
152+
final @NonNull CommandManager<C> manager,
153+
final @NonNull TypeToken<C> commandSenderClass
154+
) {
155+
this(manager, commandSenderClass, parameters -> CommandMeta.empty());
143156
}
144157

145158
/**
@@ -797,8 +810,7 @@ private <T> void parseParsers(final @NonNull T instance) {
797810

798811
final Method method = commandDescriptor.method();
799812
final CommandManager<C> manager = this.manager;
800-
final SimpleCommandMeta.Builder metaBuilder = SimpleCommandMeta.builder()
801-
.with(this.metaFactory.apply(method));
813+
final CommandMetaBuilder metaBuilder = CommandMeta.builder().with(this.metaFactory.apply(method));
802814
if (methodOrClassHasAnnotation(method, Confirmation.class)) {
803815
metaBuilder.with(CommandConfirmationManager.META_CONFIRMATION_REQUIRED, true);
804816
}

cloud-annotations/src/test/java/cloud/commandframework/annotations/AnnotationParserTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import cloud.commandframework.arguments.suggestion.SuggestionProvider;
3939
import cloud.commandframework.context.CommandContext;
4040
import cloud.commandframework.context.CommandInput;
41-
import cloud.commandframework.meta.SimpleCommandMeta;
4241
import io.leangen.geantyref.TypeToken;
4342
import java.lang.annotation.ElementType;
4443
import java.lang.annotation.Retention;
@@ -72,7 +71,7 @@ class AnnotationParserTest {
7271
@BeforeAll
7372
void setup() {
7473
manager = new TestCommandManager();
75-
annotationParser = new AnnotationParser<>(manager, TestCommandSender.class, p -> SimpleCommandMeta.empty());
74+
annotationParser = new AnnotationParser<>(manager, TestCommandSender.class);
7675
manager.parserRegistry().registerNamedParserSupplier("potato", p -> new StringParser<>(StringParser.StringMode.SINGLE));
7776
/* Register a suggestion provider */
7877
manager.parserRegistry().registerSuggestionProvider(

cloud-annotations/src/test/java/cloud/commandframework/annotations/TestCommandManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import cloud.commandframework.CommandManager;
2727
import cloud.commandframework.execution.CommandExecutionCoordinator;
2828
import cloud.commandframework.internal.CommandRegistrationHandler;
29-
import cloud.commandframework.meta.SimpleCommandMeta;
3029
import org.checkerframework.checker.nullness.qual.NonNull;
3130

3231
public class TestCommandManager extends CommandManager<TestCommandSender> {
@@ -35,11 +34,6 @@ public TestCommandManager() {
3534
super(CommandExecutionCoordinator.simpleCoordinator(), CommandRegistrationHandler.nullCommandRegistrationHandler());
3635
}
3736

38-
@Override
39-
public final SimpleCommandMeta createDefaultCommandMeta() {
40-
return SimpleCommandMeta.empty();
41-
}
42-
4337
@Override
4438
public final boolean hasPermission(
4539
final @NonNull TestCommandSender sender,

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/ArgumentDrivenCommandsTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import cloud.commandframework.annotations.SyntaxParser;
3636
import cloud.commandframework.annotations.TestCommandManager;
3737
import cloud.commandframework.annotations.TestCommandSender;
38-
import cloud.commandframework.meta.SimpleCommandMeta;
3938
import java.lang.annotation.ElementType;
4039
import java.lang.annotation.Retention;
4140
import java.lang.annotation.RetentionPolicy;
@@ -63,8 +62,7 @@ void setup() {
6362
this.commandManager = new TestCommandManager();
6463
this.annotationParser = new AnnotationParser<>(
6564
this.commandManager,
66-
TestCommandSender.class,
67-
p -> SimpleCommandMeta.empty()
65+
TestCommandSender.class
6866
);
6967
}
7068

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/MethodSuggestionProviderTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import cloud.commandframework.context.CommandContext;
3333
import cloud.commandframework.context.CommandContextFactory;
3434
import cloud.commandframework.context.StandardCommandContextFactory;
35-
import cloud.commandframework.meta.SimpleCommandMeta;
3635
import java.util.Collections;
3736
import java.util.List;
3837
import java.util.Set;
@@ -56,8 +55,7 @@ void setup() {
5655
this.commandManager = new TestCommandManager();
5756
this.annotationParser = new AnnotationParser<>(
5857
this.commandManager,
59-
TestCommandSender.class,
60-
p -> SimpleCommandMeta.empty()
58+
TestCommandSender.class
6159
);
6260
}
6361

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/RepeatableCommandMethodTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import cloud.commandframework.annotations.TestCommandSender;
3131
import cloud.commandframework.context.CommandContext;
3232
import cloud.commandframework.execution.CommandResult;
33-
import cloud.commandframework.meta.SimpleCommandMeta;
3433
import org.checkerframework.checker.nullness.qual.NonNull;
3534
import org.junit.jupiter.api.BeforeEach;
3635
import org.junit.jupiter.api.Test;
@@ -50,8 +49,7 @@ void setup() {
5049
this.commandManager = new TestCommandManager();
5150
this.annotationParser = new AnnotationParser<>(
5251
this.commandManager,
53-
TestCommandSender.class,
54-
p -> SimpleCommandMeta.empty()
52+
TestCommandSender.class
5553
);
5654
}
5755

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/RepeatableFlagTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@
2929
import cloud.commandframework.annotations.Flag;
3030
import cloud.commandframework.annotations.TestCommandManager;
3131
import cloud.commandframework.annotations.TestCommandSender;
32-
import cloud.commandframework.arguments.parser.StandardParameters;
33-
import cloud.commandframework.execution.CommandExecutionCoordinator;
3432
import cloud.commandframework.execution.CommandResult;
35-
import cloud.commandframework.internal.CommandRegistrationHandler;
36-
import cloud.commandframework.meta.CommandMeta;
37-
import cloud.commandframework.meta.SimpleCommandMeta;
38-
import io.leangen.geantyref.TypeToken;
3933
import java.util.Collection;
4034
import org.junit.jupiter.api.BeforeEach;
4135
import org.junit.jupiter.api.Test;
@@ -51,8 +45,7 @@ void setup() {
5145
this.commandManager = new TestCommandManager();
5246
final AnnotationParser<TestCommandSender> annotationParser = new AnnotationParser<>(
5347
this.commandManager,
54-
TestCommandSender.class,
55-
p -> SimpleCommandMeta.empty()
48+
TestCommandSender.class
5649
);
5750
annotationParser.parse(new TestClassA());
5851
}

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/RequiredSenderDeductionTest.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import cloud.commandframework.annotations.CommandMethod;
2929
import cloud.commandframework.execution.CommandExecutionCoordinator;
3030
import cloud.commandframework.internal.CommandRegistrationHandler;
31-
import cloud.commandframework.meta.CommandMeta;
32-
import cloud.commandframework.meta.SimpleCommandMeta;
3331
import io.leangen.geantyref.TypeToken;
3432
import java.util.concurrent.CompletionException;
3533
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -55,17 +53,11 @@ public boolean hasPermission(
5553
) {
5654
return true;
5755
}
58-
59-
@Override
60-
public @NonNull CommandMeta createDefaultCommandMeta() {
61-
return SimpleCommandMeta.empty();
62-
}
6356
};
6457
AnnotationParser<SuperSender<?>> annotationParser = new AnnotationParser<>(
6558
this.commandManager,
6659
new TypeToken<SuperSender<?>>() {
67-
},
68-
parameters -> SimpleCommandMeta.empty()
60+
}
6961
);
7062
annotationParser.parse(new TestClassA());
7163
}

cloud-annotations/src/test/java/cloud/commandframework/annotations/feature/StringProcessingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void setup() {
6060
this.annotationParser = new AnnotationParser<>(
6161
this.commandManager,
6262
TestCommandSender.class,
63-
p -> CommandMeta.simple().build()
63+
p -> CommandMeta.builder().build()
6464
);
6565
}
6666

cloud-annotations/src/test/java/cloud/commandframework/annotations/issue/Issue262.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import cloud.commandframework.annotations.CommandMethod;
3131
import cloud.commandframework.annotations.TestCommandManager;
3232
import cloud.commandframework.annotations.TestCommandSender;
33-
import cloud.commandframework.meta.SimpleCommandMeta;
3433
import org.junit.jupiter.api.BeforeEach;
3534
import org.junit.jupiter.api.Test;
3635
import org.junit.jupiter.api.extension.ExtendWith;
@@ -57,8 +56,7 @@ void setup() {
5756
this.commandHelpHandler = this.manager.createCommandHelpHandler();
5857
this.annotationParser = new AnnotationParser<>(
5958
this.manager,
60-
TestCommandSender.class,
61-
(parameters) -> SimpleCommandMeta.empty()
59+
TestCommandSender.class
6260
);
6361
}
6462

0 commit comments

Comments
 (0)