Get all classes with a specific annotation

Hey, I would like to get all the classes having an annotation named: "Command". Make sure not to have indicated the "commands" package if possible. My project would be to make a kind of commandHandler which will load all the commands in a map. - @ Command
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Command {
String name();
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Command {
String name();
}
- Command Help
@Command(name = "help")
public class HelpCommand implements CommandRunner {

@Override
public void run(ArgumentParser parser, Subparsers subparsers) {
parser.printHelp();
}
}
@Command(name = "help")
public class HelpCommand implements CommandRunner {

@Override
public void run(ArgumentParser parser, Subparsers subparsers) {
parser.printHelp();
}
}
5 Replies
JavaBot
JavaBot2y ago
This post has been reserved for your question.
Hey @Max! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
0x150
0x1502y ago
GitHub
GitHub - ronmamo/reflections: Java runtime metadata analysis
Java runtime metadata analysis. Contribute to ronmamo/reflections development by creating an account on GitHub.
Max
MaxOP2y ago
Yesss thanks, I saw her moments after posting the message. But thanks anyway ^^
JavaBot
JavaBot2y ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot2y ago
Post Closed
This post has been closed by <@358629612584173568>.

Did you find this page helpful?