class ActivitiHelper {

    public Integer getExpressionVariableAsInteger(Expression expression, DelegateExecution execution, String variableName, boolean isRequired)
        throws IllegalArgumentException
    {
        Integer variableInteger = null;

        String variableString = getExpressionVariableAsString(expression, execution);

        if (isRequired && StringUtils.isBlank(variableString))
        {
            throw new IllegalArgumentException("\"" + variableName + "\" must be specified.");
        }
        if (isRequired || StringUtils.isNotBlank(variableString))
        {
            try
            {
                variableInteger = Integer.parseInt(getExpressionVariableAsString(expression, execution));
            }
            catch (Exception ex)
            {
                throw new IllegalArgumentException("\"" + variableName + "\" must be a valid integer value.", ex);
            }
        }
        return variableInteger;
    }

}