Search in sources :

Example 1 with TaskActionParam

use of org.motechproject.tasks.annotations.TaskActionParam in project motech by motech.

the class TaskAnnotationBeanPostProcessor method getActionParams.

private SortedSet<ActionParameter> getActionParams(Method method) {
    SortedSet<ActionParameter> parameters = new TreeSet<>();
    int order = 0;
    for (Annotation[] annotations : method.getParameterAnnotations()) {
        for (Annotation annotation : annotations) {
            if (annotation instanceof TaskActionParam) {
                LOGGER.debug("The @TaskActionParam annotation was found in parameters from method: {}", method.getName());
                TaskActionParam param = (TaskActionParam) annotation;
                LOGGER.debug("Task action parameter: {} added", param.displayName());
                parameters.add(new ActionParameterBuilder().setDisplayName(param.displayName()).setKey(param.key()).setType(param.type()).setOrder(order).setRequired(param.required()).build());
                ++order;
            }
        }
    }
    return parameters.isEmpty() ? null : parameters;
}
Also used : ActionParameterBuilder(org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder) TreeSet(java.util.TreeSet) TaskActionParam(org.motechproject.tasks.annotations.TaskActionParam) ActionParameter(org.motechproject.tasks.domain.mds.channel.ActionParameter) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)1 TreeSet (java.util.TreeSet)1 TaskActionParam (org.motechproject.tasks.annotations.TaskActionParam)1 ActionParameter (org.motechproject.tasks.domain.mds.channel.ActionParameter)1 ActionParameterBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionParameterBuilder)1