@Override public Set<Entry<String, ConfigValue>> entrySet() { return c.entrySet(); }
private void addConfig(Config config) { if (m_config != null) m_config = config.withFallback(m_config); else m_config = config; for (Map.Entry<String, ConfigValue> entry : m_config.entrySet()) { m_keys.add(entry.getKey()); } }
@Test public void testLoad() { Map<String, String> map = new HashMap<>(); CC.cfg.entrySet().forEach(e -> print(e.getKey(), e.getValue(), map)); List<String> list = new ArrayList<>(map.values()); Collections.sort(list); list.forEach(s -> System.out.println(s.substring(s.indexOf(".") + 1) + ",")); }
private static Map<String, Object> toMap(Config config) { Map<String, Object> map = new HashMap<>(); for (Map.Entry<String, ConfigValue> entry: config.entrySet()) { map.put(entry.getKey(), entry.getValue().unwrapped()); } return map; } }
static void addOverrides(Configuration conf, Config config) { for(Map.Entry<String, ConfigValue> entry: config.entrySet()) { String propName = entry.getKey(); if (propName.endsWith(STRIP_SUFFIX)) { propName = propName.substring(0, propName.length() - STRIP_SUFFIX.length()); } conf.set(propName, entry.getValue().unwrapped().toString()); } }
private static Map<Object, Object> settings(final Env env, final Config config) { Map<Object, Object> $ = new HashMap<>(); config.getConfig("hibernate") .entrySet() .stream() .filter(it -> !it.getKey().equals("packagesToScan")) .forEach(e -> $.put("hibernate." + e.getKey(), e.getValue().unwrapped())); return $; } }
private Map<String, String> environment(Config conf) { Map<String, String> vars = new HashMap<>(System.getenv()); conf.entrySet().forEach(e -> vars.put(e.getKey(), e.getValue().unwrapped().toString())); vars.put("NODE_ENV", conf.getString("application.env").equals("dev") ? "development" : "production"); return vars; }
private Properties props(final Config config) { Properties props = new Properties(); config.entrySet().forEach(prop -> { Object value = prop.getValue().unwrapped(); props.setProperty("ebean." + prop.getKey(), value.toString()); }); return props; }
protected String toPropertiesLine(final Config properties, final String sep) { StringBuilder plainprops = new StringBuilder(); for (Entry<String, ConfigValue> property : properties.entrySet()) { plainprops.append(property.getKey()) .append("=") .append(property.getValue().unwrapped().toString()) .append(sep); } if (plainprops.length() > 0) { plainprops.setLength(plainprops.length() - sep.length()); } return plainprops.toString(); }
private Properties properties(final Config config) { Properties props = new Properties(); // dump config.getConfig("freemarker").entrySet().forEach(e -> { String name = e.getKey(); String value = e.getValue().unwrapped().toString(); log.debug(" freemarker.{} = {}", name, value); props.setProperty(name, value); }); // this is a jooby option props.remove("cache"); return props; }
private Properties properties(final Config config) { Properties props = new Properties(); // dump config.getConfig("org.quartz").entrySet().forEach( e -> props.setProperty("org.quartz." + e.getKey(), e.getValue().unwrapped().toString())); String store = props.getProperty("org.quartz.jobStore.class"); if (JobStoreTX.class.getName().equals(store)) { String ds = props.getProperty(DS); if (ds == null) { throw new IllegalArgumentException("Missing property: " + DS); } } return props; }
public static ReplicationMetaData buildMetaData(Config config) { if (!config.hasPath(ReplicationConfiguration.METADATA)) { return new ReplicationMetaData(Optional.<Map<String, String>> absent()); } Config metaDataConfig = config.getConfig(ReplicationConfiguration.METADATA); Map<String, String> metaDataValues = new HashMap<>(); Set<Map.Entry<String, ConfigValue>> meataDataEntry = metaDataConfig.entrySet(); for (Map.Entry<String, ConfigValue> entry : meataDataEntry) { metaDataValues.put(entry.getKey(), metaDataConfig.getString(entry.getKey())); } ReplicationMetaData metaData = new ReplicationMetaData(Optional.of(metaDataValues)); return metaData; }
@SuppressWarnings({"unchecked", "rawtypes"}) private static Properties props(final Config config) { Properties props = new Properties(); config.withoutPath("run").entrySet().forEach(prop -> { Object value = prop.getValue().unwrapped(); if (value instanceof List) { value = ((List) value).stream().collect(Collectors.joining(",")); } props.setProperty("flyway." + prop.getKey(), value.toString()); }); return props; }
private Properties toProperties(final Config config) { Properties properties = new Properties(); config.withoutPath("session").entrySet().forEach(prop -> properties.setProperty("hazelcast." + prop.getKey(), prop.getValue().unwrapped().toString())); return properties; }
/** * Check that every key-value in superConfig is in subConfig */ public static boolean verifySubset(Config superConfig, Config subConfig) { for (Map.Entry<String, ConfigValue> entry : subConfig.entrySet()) { if (!superConfig.hasPath(entry.getKey()) || !superConfig.getValue(entry.getKey()).unwrapped() .equals(entry.getValue().unwrapped())) { return false; } } return true; }
public void printConfig(Config config){ Set<Map.Entry<String,ConfigValue>> entrySet = config.entrySet(); for(Map.Entry<String,ConfigValue> entry: entrySet){ System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue()); } }
public void printConfig(Config config){ Set<Map.Entry<String,ConfigValue>> entrySet = config.entrySet(); for(Map.Entry<String,ConfigValue> entry: entrySet){ System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue()); } }
private void checkValuesForIdentityOwnConfig(Config ownConfig){ Assert.assertTrue(ownConfig.entrySet().size() == 2 ); Assert.assertTrue(ownConfig.getString("keyOf_identity").equals("valueOf_identity")); Assert.assertTrue(ownConfig.getString("generalKey").equals("valueOf_generalKey_identity")); }
private static Config getStateStoreConfig(Config config, String rootDir, String dbTableKey) { Config fallbackConfig = ConfigFactory.empty() .withFallback(config) .withValue(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, ConfigValueFactory.fromAnyRef(rootDir)) .withValue(ConfigurationKeys.STATE_STORE_DB_TABLE_KEY, ConfigValueFactory.fromAnyRef(dbTableKey)); Config scopedConfig = ConfigFactory.empty(); for (Map.Entry<String, ConfigValue> entry : config.withOnlyPath(ConfigurationKeys.INTERMEDIATE_STATE_STORE_PREFIX).entrySet()) { scopedConfig.withValue(entry.getKey().substring(ConfigurationKeys.INTERMEDIATE_STATE_STORE_PREFIX.length()), entry.getValue()); } return scopedConfig.withFallback(fallbackConfig); } }
static io.vavr.collection.Map<String, ?> loadConfigFromString(String string) { Config config = ConfigFactory.parseString(string, ConfigParseOptions.defaults().prependIncluder(new ConfigIncluder() { private ConfigIncluder parent = null; public ConfigObject include(ConfigIncludeContext context, String what) { return ConfigFactory.parseFileAnySyntax(new File(what)).root(); } public ConfigIncluder withFallback(ConfigIncluder fallback) { parent = fallback; return this; } })); config = config.resolve(); return HashSet.ofAll(config.entrySet()).toMap(entry -> Tuple.of(entry.getKey(), entry.getValue().unwrapped())); }