in velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/MathUtils.java [177:217]
public static Number wrapPrimitive (long value, Class<?> type)
{
if (type == Byte.class)
{
if (value > Byte.MAX_VALUE || value < Byte.MIN_VALUE)
{
type = Short.class;
}
else
{
return (byte) value;
}
}
if (type == Short.class)
{
if (value > Short.MAX_VALUE || value < Short.MIN_VALUE)
{
type = Integer.class;
}
else
{
return (short) value;
}
}
if (type == Integer.class)
{
if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE)
{
type = Long.class;
}
else
{
return (int) value;
}
}
if (type == Long.class)
{
return value;
}
return BigInteger.valueOf(value);
}