use of org.cubeengine.butler.parametric.InvokableMethod in project core by CubeEngine.
the class CubeCommandManager method addCommands.
/**
* Creates {@link org.cubeengine.butler.parametric.BasicParametricCommand} for all methods annotated as a command
* in the given commandHolder and add them to the given dispatcher
*
* @param dispatcher the dispatcher to add the commands to
* @param owner the module owning the commands
* @param commandHolder the command holder containing the command-methods
*/
@SuppressWarnings("unchecked")
@Override
public void addCommands(Dispatcher dispatcher, Object owner, Object commandHolder) {
Set<CommandBase> cmds = this.commands.get(owner);
if (cmds == null) {
cmds = new HashSet<>();
}
this.commands.put(owner, cmds);
dispatcher = new OwnedDispatcher(dispatcher, owner);
for (Method method : ParametricBuilder.getMethods(commandHolder.getClass())) {
CommandBuilder<InvokableMethod> builder = getProviders().getBuilder(InvokableMethod.class);
CommandBase cmd = builder.buildCommand(dispatcher, new InvokableMethod(method, commandHolder));
if (cmd != null) {
dispatcher.addCommand(cmd);
cmds.add(cmd);
}
}
}
Aggregations