{
throw new NullPointerException("Output condition by count requires a non-null callback");
}
// Check if a variable is present
VariableReader reader = null;
if (outputLimitSpec.getVariableName() != null)
{
reader = agentInstanceContext.getStatementContext().getVariableService().getReader(outputLimitSpec.getVariableName(), agentInstanceContext.getAgentInstanceId());
if (reader == null)
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' has not been declared");
}
}
if(outputLimitSpec.getRateType() == OutputLimitRateType.CRONTAB)
{
return new OutputConditionPolledCrontab(outputLimitSpec.getCrontabAtSchedule(), agentInstanceContext);
}
else if(outputLimitSpec.getRateType() == OutputLimitRateType.WHEN_EXPRESSION)
{
return new OutputConditionPolledExpression(outputLimitSpec.getWhenExpressionNode(), outputLimitSpec.getThenExpressions(), agentInstanceContext);
}
else if(outputLimitSpec.getRateType() == OutputLimitRateType.EVENTS)
{
if (log.isDebugEnabled())
{
log.debug(".createCondition creating OutputConditionCount with event rate " + outputLimitSpec);
}
if ((reader != null) && (!JavaClassHelper.isNumericNonFP(reader.getVariableMetaData().getType())))
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be type integer, long or short");
}
int rate = -1;
if (outputLimitSpec.getRate() != null)
{
rate = outputLimitSpec.getRate().intValue();
}
return new OutputConditionPolledCount(rate, reader);
}
else
{
if ((reader != null) && (!JavaClassHelper.isNumeric(reader.getVariableMetaData().getType())))
{
throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be of numeric type");
}
return new OutputConditionPolledTime(outputLimitSpec.getTimePeriodExpr(), agentInstanceContext);