ijokarumawak commented on issue #3371: NIFI-6117: Fix BIGINT handling in DataTypeUtils URL: https://github.com/apache/nifi/pull/3371#issuecomment-472667914 @mattyb149 In order to align with other numeric types, I suggest separating the existing isIntegral method like below. ```java public static boolean isBigIntTypeCompatible(final Object value) { return isNumberTypeCompatible(value, s -> isIntegral(s)) } // We need something similar to isIntegral, but the value can be larger than the max long. // So let's extract the String validation part like this. private static boolean isIntegral(final String value) { if (value == null || value.isEmpty()) { return false; } int initialPosition = 0; final char firstChar = value.charAt(0); if (firstChar == '+' || firstChar == '-') { initialPosition = 1; if (value.length() == 1) { return false; } } for (int i = initialPosition; i < value.length(); i++) { if (!Character.isDigit(value.charAt(i))) { return false; } } return true; } // This one works as is. But we can use the same isIntegral(String) part. private static boolean isIntegral(final String value, final long minValue, final long maxValue) { if (!isIntegral(value)) { return false; } try { final long longValue = Long.parseLong(value); return longValue >= minValue && longValue <= maxValue; } catch (final NumberFormatException nfe) { // In case the value actually exceeds the max value of a Long return false; } } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
