Search in sources :

Example 1 with CliAvailabilityIndicator

use of org.springframework.roo.shell.CliAvailabilityIndicator in project spring-roo by spring-projects.

the class HelpServiceImpl method add.

public final void add(final CommandMarker command) {
    synchronized (mutex) {
        commands.add(command);
        for (final Method method : command.getClass().getMethods()) {
            final CliAvailabilityIndicator availability = method.getAnnotation(CliAvailabilityIndicator.class);
            if (availability != null) {
                Validate.isTrue(method.getParameterTypes().length == 0, "CliAvailabilityIndicator is only legal for 0 parameter methods ('%s')", method.toGenericString());
                Validate.isTrue(method.getReturnType().equals(Boolean.TYPE), "CliAvailabilityIndicator is only legal for primitive boolean return types (%s)", method.toGenericString());
                for (final String cmd : availability.value()) {
                    Validate.isTrue(!availabilityIndicators.containsKey(cmd), "Cannot specify an availability indicator for '%s' more than once", cmd);
                    availabilityIndicators.put(cmd, new MethodTarget(method, command));
                }
            }
        }
    }
}
Also used : CliAvailabilityIndicator(org.springframework.roo.shell.CliAvailabilityIndicator) MethodTarget(org.springframework.roo.shell.MethodTarget) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 CliAvailabilityIndicator (org.springframework.roo.shell.CliAvailabilityIndicator)1 MethodTarget (org.springframework.roo.shell.MethodTarget)1