Class NumericPropertyParser

java.lang.Object
org.odpi.openmetadata.frameworks.connectors.NumericPropertyParser

public class NumericPropertyParser extends Object
Turns a configuration property or request parameter into a whole number. Configuration properties arrive from JSON, so a value set as 30 may reach the connector as an Integer, a Long, a Double (30.0) or a String, and request parameters are always Strings that may carry surrounding spaces. Parsing the value's string form with Integer.parseInt rejected 30.0 and " 30" with a bare NumberFormatException that named neither the property nor its value. Any representation of a whole number in range is now accepted, and anything else is reported with the property's name.
  • Constructor Details

    • NumericPropertyParser

      public NumericPropertyParser()
  • Method Details

    • getIntConfigurationProperty

      public static int getIntConfigurationProperty(String propertyName, Object propertyValue)
      Return the value of a configuration property as an int.
      Parameters:
      propertyName - name of the configuration property
      propertyValue - value of the configuration property (not null)
      Returns:
      int value
      Throws:
      OMFRuntimeException - the value is not a whole number in the range of an int
    • getLongConfigurationProperty

      public static long getLongConfigurationProperty(String propertyName, Object propertyValue)
      Return the value of a configuration property as a long.
      Parameters:
      propertyName - name of the configuration property
      propertyValue - value of the configuration property (not null)
      Returns:
      long value
      Throws:
      OMFRuntimeException - the value is not a whole number in the range of a long
    • getIntRequestParameter

      public static int getIntRequestParameter(String parameterName, String parameterValue)
      Return the value of a request parameter as an int.
      Parameters:
      parameterName - name of the request parameter
      parameterValue - value of the request parameter (not null)
      Returns:
      int value
      Throws:
      OMFRuntimeException - the value is not a whole number in the range of an int
    • getLongRequestParameter

      public static long getLongRequestParameter(String parameterName, String parameterValue)
      Return the value of a request parameter as a long.
      Parameters:
      parameterName - name of the request parameter
      parameterValue - value of the request parameter (not null)
      Returns:
      long value
      Throws:
      OMFRuntimeException - the value is not a whole number in the range of a long