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));
}
}
}
}
}
Aggregations