@Test public void testResolveConfig_withParent() throws IOException { File f_stage_db = copyResourceTo("/net/morimekta/providence/config/files/stage_db.cfg", temp.getRoot()); File f_stage_nocred = copyResourceTo("/net/morimekta/providence/config/files/stage_nocred.cfg", temp.getRoot()); ProvidenceConfig config = new ProvidenceConfig(registry, null, true); ConfigSupplier<Database,Database._Field> stage_db = config.resolveConfig(f_stage_db); ConfigSupplier<Database,Database._Field> stage_nocred = config.resolveConfig(f_stage_nocred, stage_db); assertEquals("{\n" + " uri = \"jdbc:h2:localhost:mem\"\n" + " driver = \"org.h2.Driver\"\n" + "}", debugString(stage_nocred.get())); }
@Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); @Nonnull @Override @SuppressWarnings("unchecked") ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile,
                                       @Nullable ConfigSupplier<M, F> parentConfig); @Nonnull M getConfig(@Nonnull File configFile); @Nonnull M getConfig(@Nonnull File configFile, @Nonnull M parent); }
ProvidenceConfig implements ConfigResolver { @Nonnull @Override @SuppressWarnings("unchecked") public <M extends PMessage<M, F>, F extends PField> ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile, @Nullable ConfigSupplier<M, F> parentConfig) throws ProvidenceConfigException { Path configPath = canonicalFileLocation(configFile.toPath()); String path = null; if (parentConfig == null) { path = configPath.toString(); if (loaded.containsKey(path)) { return (ConfigSupplier<M, F>) loaded.get(path); } } ProvidenceConfigSupplier<M, F> supplier = new ProvidenceConfigSupplier<>( configFile, parentConfig, watcher, parser, clock); if (parentConfig == null) { loaded.put(path, supplier); } return supplier; } ProvidenceConfig(TypeRegistry registry);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher, boolean strict);  ProvidenceConfig(@Nonnull TypeRegistry registry,
                            @Nullable FileWatcher watcher,
                            boolean strict,
                            @Nonnull Clock clock); @Nonnull @Override @SuppressWarnings("unchecked") ConfigSupplier<M, F> resolveConfig(@Nonnull File configFile,
                                       @Nullable ConfigSupplier<M, F> parentConfig); @Nonnull M getConfig(@Nonnull File configFile); @Nonnull M getConfig(@Nonnull File configFile, @Nonnull M parent);  }