@Test public void testGetLong_AlternativeKeys() { config.put( "no-long", "text" ); config.put( "some-long", 23 ); assertEquals( 23, ConfigUtils.getLong( config, 0, "no-long", "some-long" ) ); }
public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Number ) { return ( (Number) value ).longValue(); } try { return Long.valueOf( (String) value ); } catch ( Exception e ) { } } return defaultValue; }
ConfigUtils { public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Number ) { return ( (Number) value ).longValue(); } try { return Long.valueOf( (String) value ); } catch ( Exception e ) { } } return defaultValue; } }
ConfigUtils { public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Number ) { return ( (Number) value ).longValue(); } try { return Long.valueOf( (String) value ); } catch ( Exception e ) { } } return defaultValue; } private  ConfigUtils(); }
ConfigUtils { public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Number ) { return ( (Number) value ).longValue(); } try { return Long.valueOf( (String) value ); } catch ( Exception e ) { } } return defaultValue; } private  ConfigUtils(); static Object getObject( Map<?, ?> properties, Object defaultValue, String... keys ); static Object getObject( RepositorySystemSession session, Object defaultValue, String... keys ); static String getString( Map<?, ?> properties, String defaultValue, String... keys ); static String getString( RepositorySystemSession session, String defaultValue, String... keys ); static int getInteger( Map<?, ?> properties, int defaultValue, String... keys ); static int getInteger( RepositorySystemSession session, int defaultValue, String... keys ); static long getLong( Map<?, ?> properties, long defaultValue, String... keys ); static long getLong( RepositorySystemSession session, long defaultValue, String... keys ); static float getFloat( Map<?, ?> properties, float defaultValue, String... keys ); static float getFloat( RepositorySystemSession session, float defaultValue, String... keys ); static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ); static boolean getBoolean( RepositorySystemSession session, boolean defaultValue, String... keys ); static List<?> getList( Map<?, ?> properties, List<?> defaultValue, String... keys ); static List<?> getList( RepositorySystemSession session, List<?> defaultValue, String... keys ); static Map<?, ?> getMap( Map<?, ?> properties, Map<?, ?> defaultValue, String... keys ); static Map<?, ?> getMap( RepositorySystemSession session, Map<?, ?> defaultValue, String... keys ); }
ConfigUtils { public static long getLong( Map<?, ?> properties, long defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Number ) { return ( (Number) value ).longValue(); } try { return Long.valueOf( (String) value ); } catch ( Exception e ) { } } return defaultValue; } private  ConfigUtils(); static Object getObject( Map<?, ?> properties, Object defaultValue, String... keys ); static Object getObject( RepositorySystemSession session, Object defaultValue, String... keys ); static String getString( Map<?, ?> properties, String defaultValue, String... keys ); static String getString( RepositorySystemSession session, String defaultValue, String... keys ); static int getInteger( Map<?, ?> properties, int defaultValue, String... keys ); static int getInteger( RepositorySystemSession session, int defaultValue, String... keys ); static long getLong( Map<?, ?> properties, long defaultValue, String... keys ); static long getLong( RepositorySystemSession session, long defaultValue, String... keys ); static float getFloat( Map<?, ?> properties, float defaultValue, String... keys ); static float getFloat( RepositorySystemSession session, float defaultValue, String... keys ); static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ); static boolean getBoolean( RepositorySystemSession session, boolean defaultValue, String... keys ); static List<?> getList( Map<?, ?> properties, List<?> defaultValue, String... keys ); static List<?> getList( RepositorySystemSession session, List<?> defaultValue, String... keys ); static Map<?, ?> getMap( Map<?, ?> properties, Map<?, ?> defaultValue, String... keys ); static Map<?, ?> getMap( RepositorySystemSession session, Map<?, ?> defaultValue, String... keys );  }