isCoercible = true;
break;
}
}
if (!isCoercible) {
throw new ArgumentTypeMismatchException(Arrays.toString(args[i].getAllowedTypes()),
child.getDataType().toString(), info.getName() + " argument " + (i + 1));
}
if (child instanceof LiteralExpression) {
LiteralExpression valueExp = (LiteralExpression) child;
LiteralExpression minValue = args[i].getMinValue();
LiteralExpression maxValue = args[i].getMaxValue();
if (minValue != null && minValue.getDataType().compareTo(minValue.getValue(), valueExp.getValue(), valueExp.getDataType()) > 0) {
throw new ValueRangeExcpetion(minValue, maxValue == null ? "" : maxValue, valueExp.getValue(), info.getName() + " argument " + (i + 1));
}
if (maxValue != null && maxValue.getDataType().compareTo(maxValue.getValue(), valueExp.getValue(), valueExp.getDataType()) < 0) {
throw new ValueRangeExcpetion(minValue == null ? "" : minValue, maxValue, valueExp.getValue(), info.getName() + " argument " + (i + 1));
}
}
}
if (args[i].isConstant() && ! (child instanceof LiteralExpression) ) {
throw new ArgumentTypeMismatchException("constant", child.toString(), info.getName() + " argument " + (i + 1));
}
if (!args[i].getAllowedValues().isEmpty()) {
Object value = ((LiteralExpression)child).getValue();
if (!args[i].getAllowedValues().contains(value.toString().toUpperCase())) {
throw new ArgumentTypeMismatchException(Arrays.toString(args[i].getAllowedValues().toArray(new String[0])),
value.toString(), info.getName() + " argument " + (i + 1));
}
}
}
}