public <T> T get(String key, T def) { Object value = get(key); if (value instanceof Config && ((Config) value).isEmpty() && !(def instanceof Config)) return def; return (T) value; }
public <T> T get(String key, T def) { Object value = get(key); if (value instanceof Config && ((Config) value).isEmpty() && !(def instanceof Config)) return def; return (T) value; }
public <T> T get(String key, Supplier<T> def) { Object value = get(key); if (value instanceof Config && ((Config) value).isEmpty()) return def.supply(); return (T) value; }
public <T> T get(String key, Supplier<T> def) { Object value = get(key); if (value instanceof Config && ((Config) value).isEmpty()) return def.supply(); return (T) value; }
protected void readProfiles(Config config) { if (config == null || config.isEmpty()) return; Config environments = (Config) config.remove("environments"); if (environments != null) { Config env = environments.config(environment.shortName); if (env != null) config.merge(env); env = environments.config(environment.name().toLowerCase()); if (env != null) config.merge(env); } Config profiles = (Config) config.remove("profiles"); if (profiles == null || profiles.isEmpty()) return; for (String profile : this.profiles) { Config subConfig = profiles.config(profile); readProfiles(subConfig); config.merge(subConfig); } if (this.config != config) this.config.merge(config); }
if (config.isEmpty()) { reflection.setObject(t, null); break;
if (config.isEmpty()) { reflection.setObject(t, null); break;
@Test public void test_profiles_5() throws IOException, NoSuchMethodException, NoSuchFieldException, ClassNotFoundException, InterruptedException { server.setEnvironment(Environment.TEST); server.start(); Assert.assertEquals("bar", server.getConfig().config("foo").get("v")); Assert.assertTrue(server.getConfig().get("bar") instanceof Config); Assert.assertTrue(((Config) server.getConfig().get("bar")).isEmpty()); }