Class PessimisticNumberParser

  • public final class PessimisticNumberParser
    extends Object
    An old-style query might pass positional numbers of Query parameters as strings. This implies we always need to attempt parsing string parameters to see if this deprecated feature is being used, but parsing leads to catching (and ignoring) NumberFormatException at runtime which is a performance problem, especially as the parse would fail each time a non-deprecated form is processed. This class is meant to avoid the need to allocate these exceptions at runtime. Use this class to convert String to Integer when it's unlikely to be successful: if you expect it to be a normal number, for example when a non successful parsing would be an error, using this utility is just an overhead.
    • Method Detail

      • toNumberOrNull

        public static Integer toNumberOrNull​(String parameterName)