protected static int getIntSetting ( Map < String , Object > settings , String key , int defaultVal ) throws IllegalArgumentException { if ( settings . containsKey ( key ) ) { final Object objectValue = settings . get ( key ) ; if ( objectValue == null ) { throw new IllegalArgumentException ( "Setting '" + key + " null" ) ; } final String value = objectValue . toString ( ) ; try { return Integer . parseInt ( value ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Setting '" + key + "=" + value + "' is not an integer" , e ) ; } } else { return defaultVal ; } }
Gets an int value for the setting returning the default value if not specified .