Search in sources :

Example 1 with Parameter

use of org.jowidgets.cap.service.api.annotation.Parameter in project jo-client-platform by jo-source.

the class ExecutorAnnotationPostProcessor method evaluateParameterExpression.

IMaybe<Object> evaluateParameterExpression(final Object parameter, final Method method, final int argIndex) {
    final Annotation[] annotations = method.getParameterAnnotations()[argIndex];
    for (final Annotation annotation : annotations) {
        if (annotation instanceof Parameter) {
            final Parameter paramAnno = (Parameter) annotation;
            if (!expressions.containsKey(paramAnno)) {
                expressions.putIfAbsent(paramAnno, expressionParser.parseExpression(paramAnno.value()));
            }
            final Expression expression = expressions.get(paramAnno);
            return new Some<Object>(expression.getValue(parameter, method.getParameterTypes()[argIndex]));
        }
    }
    return Nothing.getInstance();
}
Also used : Some(org.jowidgets.util.maybe.Some) Expression(org.springframework.expression.Expression) Parameter(org.jowidgets.cap.service.api.annotation.Parameter) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Parameter (org.jowidgets.cap.service.api.annotation.Parameter)1 Some (org.jowidgets.util.maybe.Some)1 Expression (org.springframework.expression.Expression)1