@Validate
public static UnsignedLong parseUInt64(@NotNull final String value, @NotNull final UnsignedLong minValue,
@NotNull final UnsignedLong maxValue)
{
// parse
UnsignedLong result;
try
{
result = new UnsignedLong(value);
}
catch(Throwable e)
{
throw new NumberFormatException("The value '" + value + "' could not be parsed: " + e.getMessage());
}
// sanity check
if (result.compareTo(minValue) < 0)
throw new NumberFormatException("Value (" + result + ") was less than allowed minimum (" + minValue + ").");
if (result.compareTo(maxValue) > 0)
throw new NumberFormatException("Value (" + result + ") was more than allowed maximum (" + maxValue + ").");
return result;
}