{ // Check Range
long minVal = ObjectUtils.getLong(min);
long maxVal = ObjectUtils.getLong(max);
if (n.longValue()<minVal || n.longValue()>maxVal)
{ // Out of Range
throw new FieldValueOutOfRangeException(this, minVal, maxVal);
}
}
else if (min!=null)
{ // Check Min Value
long minVal = ObjectUtils.getLong(min);
if (n.longValue()<minVal)
{ // Out of Range
throw new FieldValueOutOfRangeException(this, minVal, false);
}
}
else if (max!=null)
{ // Check Max Value
long maxVal = ObjectUtils.getLong(max);
if (n.longValue()>maxVal)
{ // Out of Range
throw new FieldValueOutOfRangeException(this, maxVal, true);
}
}
// Check overall
if (type==DataType.DECIMAL)
{ // Convert to Decimal
BigDecimal dv = ObjectUtils.toDecimal(n);
int prec = dv.precision();
int scale = dv.scale();
// check precision and scale
double size = getSize();
int reqPrec = (int)size;
int reqScale =((int)(size*10)-(reqPrec*10));
if ((prec-scale)>(reqPrec-reqScale) || scale>reqScale)
throw new FieldValueOutOfRangeException(this);
}
}