private static Integer toInteger(String paramName, Object o, boolean required) throws BadConfig {
		if (o == null) {
			if (required)
				throw new BadConfig("Parameter \"" + paramName + "\" is required");
			return null;
		}
		if (!(o instanceof Number))
			throw new BadConfig("In parameter \"" + paramName + "\", value \"" + o + "\" should be an integer");
		return ((Number) o).intValue();
	}