@Test public void testGetBoolean_AlternativeKeys() { config.put( "no-boolean", new Object() ); config.put( "some-boolean", true ); assertEquals( true, ConfigUtils.getBoolean( config, false, "no-boolean", "some-boolean" ) ); config.put( "some-boolean", false ); assertEquals( false, ConfigUtils.getBoolean( config, true, "no-boolean", "some-boolean" ) ); }
public static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Boolean ) { return (Boolean) value; } else if ( value instanceof String ) { return Boolean.parseBoolean( (String) value ); } } return defaultValue; }
ConfigUtils { public static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Boolean ) { return (Boolean) value; } else if ( value instanceof String ) { return Boolean.parseBoolean( (String) value ); } } return defaultValue; } }
ConfigUtils { public static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Boolean ) { return (Boolean) value; } else if ( value instanceof String ) { return Boolean.parseBoolean( (String) value ); } } return defaultValue; } private  ConfigUtils(); }
ConfigUtils { public static boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Boolean ) { return (Boolean) value; } else if ( value instanceof String ) { return Boolean.parseBoolean( (String) value ); } } 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 boolean getBoolean( Map<?, ?> properties, boolean defaultValue, String... keys ) { for ( String key : keys ) { Object value = properties.get( key ); if ( value instanceof Boolean ) { return (Boolean) value; } else if ( value instanceof String ) { return Boolean.parseBoolean( (String) value ); } } 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 );  }