public static Integer getIntegerProperty ( final ServiceReference < ? > serviceReference , final String key ) { NullArgumentException . validateNotNull ( serviceReference , "Service reference" ) ; NullArgumentException . validateNotEmpty ( key , true , "Property key" ) ; final Object value = serviceReference . getProperty ( key ) ; if ( value instanceof Integer ) { return ( Integer ) value ; } else if ( value != null ) { try { return Integer . parseInt ( String . valueOf ( value ) ) ; } catch ( NumberFormatException e ) { final String message = String . format ( "Property [%s] value must be an Integer: %s" , key , e . getMessage ( ) ) ; LOG . error ( message , e ) ; return null ; } } else { return null ; } }
Returns a property as Integer .