Avoiding Reflections¶
JDA-Commands uses java.lang.reflect
in two places:
If you want to completely avoid java.lang.reflect
you have to provide your own implementations.
ClassFinder¶
ClassFinders
are used to provide instances of Class
that will be scanned for interactions or custom implementations.
You can register at the JDA-Commands Builder.
Use ClassFinder#explicit(...)
if you want to explicitly add a Class
.
Warning
Calling classFinders(...)
on the builder will override existing class finders. If you want to keep the default
reflective class finder, you have to add it again via ClassFinder#reflective(...)
.
JDACommands.builder(jda, Main.class)
.classFinders(ClassFinder.explicit(ForeignClass.class), ClassFinder.reflective(Main.class, "com.package"));
.start();
Descriptor¶
A Descriptor
takes a Class
as input and transforms it into a ClassDescription
.
Descriptors can also be registered using the @Implementation
annotation. Alternatively, register them at the JDA-Commands Builder.