Search in sources :

Example 1 with TaskPostActionParam

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

the class TaskAnnotationBeanPostProcessor method getPostActionParams.

private SortedSet<ActionParameter> getPostActionParams(Method method) {
    SortedSet<ActionParameter> parameters = new TreeSet<>();
    int order = 0;
    for (Annotation[] annotations : method.getParameterAnnotations()) {
        for (Annotation annotation : annotations) {
            if (annotation instanceof TaskPostActionParam) {
                LOGGER.debug("The @TaskPostActionParam annotation was found in parameters from method: {}", method.getName());
                TaskPostActionParam param = (TaskPostActionParam) 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) ActionParameter(org.motechproject.tasks.domain.mds.channel.ActionParameter) TaskPostActionParam(org.motechproject.tasks.annotations.TaskPostActionParam) Annotation(java.lang.annotation.Annotation)

Aggregations

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