Search in sources :

Example 1 with MethodTarget

use of org.springframework.shell.core.MethodTarget in project geode by apache.

the class CommandManager method add.

/**
   * Method to add new Commands to the parser
   *
   * @param commandMarker
   */
void add(CommandMarker commandMarker) {
    if (CommandManagerAware.class.isAssignableFrom(commandMarker.getClass())) {
        ((CommandManagerAware) commandMarker).setCommandManager(this);
    }
    commandMarkers.add(commandMarker);
    for (Method method : commandMarker.getClass().getMethods()) {
        CliCommand cliCommand = method.getAnnotation(CliCommand.class);
        CliAvailabilityIndicator availability = method.getAnnotation(CliAvailabilityIndicator.class);
        if (cliCommand == null && availability == null) {
            continue;
        }
        if (cliCommand != null) {
            helper.addCommand(cliCommand, method);
        }
        if (availability != null) {
            helper.addAvailabilityIndicator(availability, new MethodTarget(method, commandMarker));
        }
    }
}
Also used : CliAvailabilityIndicator(org.springframework.shell.core.annotation.CliAvailabilityIndicator) MethodTarget(org.springframework.shell.core.MethodTarget) CliCommand(org.springframework.shell.core.annotation.CliCommand) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 MethodTarget (org.springframework.shell.core.MethodTarget)1 CliAvailabilityIndicator (org.springframework.shell.core.annotation.CliAvailabilityIndicator)1 CliCommand (org.springframework.shell.core.annotation.CliCommand)1