static Integer getInteger ( Properties properties , String key , Integer defaultValue ) { if ( properties == null ) return defaultValue ; String value = properties . getProperty ( key ) ; if ( value == null || value . isEmpty ( ) ) return defaultValue ; int intVal ; try { intVal = Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { logger . warn ( "Cannot read property '" + key + "'. Expected integer, but got '" + value + "'. Setting default value = '" + defaultValue + "'" , e . getMessage ( ) ) ; return defaultValue ; } logger . trace ( "Read property '" + key + "' value '" + intVal + "'" ) ; return intVal ; }
returns int value of property or defaultValue if not found or invalid