/** * Executes this {@link ConditionMethod}. If the #method does not succeed a * {@link ConditionFailure} is returned. Otherwise null is returned. * * @param context * The current executing {@link ExecutionContext} * @return A {@link ConditionFailure} if condition fails, null otherwise * @throws RuleExecutionException * If execution of the condition method fails with an exception. * @see ExecutionContext * @see ConditionFailure */ public ConditionFailure execute(ExecutionContext context) throws RuleExecutionException { try { boolean valid = (boolean) ReflectionUtils.invokeMethod(getMethod(), context.getInstance()); if (!valid) { // Store information about the failed condition for later usage return new ConditionFailure(getName(), getHint()); } return null; } catch (Exception e) { throw new RuleExecutionException("Invocation of condition method failed.", context, e); } }