Package org.jibeframework.core.app.condition

Source Code of org.jibeframework.core.app.condition.AnnotatedConditionFunctionExecutor

/**
*
*/
package org.jibeframework.core.app.condition;

import org.jibeframework.core.JibeRuntimeException;
import org.jibeframework.core.service.CoreServices;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.MethodExecutor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.support.BooleanTypedValue;

public class AnnotatedConditionFunctionExecutor implements MethodExecutor {
  private String evalMethod;

  public AnnotatedConditionFunctionExecutor(String evalMethod) {
    this.evalMethod = evalMethod;
  }

  public TypedValue execute(EvaluationContext context, Object target, Object... arguments)
      throws AccessException {
    Object obj = CoreServices.getMethodService().invoke(
        org.jibeframework.core.annotation.ConditionFunction.class, evalMethod, arguments);
    if (obj instanceof Boolean) {
      Boolean result = (Boolean) obj;
      return result ? BooleanTypedValue.TRUE : BooleanTypedValue.FALSE;
    }
    throw new JibeRuntimeException("Condition evaluation methods has to have Boolean return value: "
        + evalMethod);
  }
}
TOP

Related Classes of org.jibeframework.core.app.condition.AnnotatedConditionFunctionExecutor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.