public static boolean isAncestorOrSame(ConfigKeyPath descendant, ConfigKeyPath ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (descendant.equals(ancestor)) return true; if (descendant.isRootPath()) return false; return isAncestorOrSame(descendant.getParent(), ancestor); }
public List<ConfigKeyPath> getImportsRecursively(ConfigKeyPath configKey, Optional<Config> runtimeConfig) { return new ImportTraverser<>(key -> { if (key.isRootPath()) { return new LinkedList<>(); } List<ConfigKeyPath> imports = Lists.newArrayList(); imports.addAll(Lists.reverse(getOwnImports(key, runtimeConfig))); imports.add(key.getParent()); return imports; }, this.recursiveImportMap).traverseGraphRecursively(configKey); }
if (configKeyPath.isRootPath()) { return storeRoot;
@Override public String getAbsolutePathString() { if (this.isRootPath()) { return this.getOwnPathName() + PATH_DELIMETER; } // first level children do not need to add "/" if (this.parent.isRootPath()) return this.parent.getAbsolutePathString() + this.ownName; return this.parent.getAbsolutePathString() + PATH_DELIMETER + this.ownName; }
private Config getResolvedConfigRecursive(ConfigKeyPath configKey, Set<String> alreadyLoadedPaths, Optional<Config> runtimeConfig) { if (this.cs instanceof ConfigStoreWithResolution) { return ((ConfigStoreWithResolution) this.cs).getResolvedConfig(configKey, this.version); } if (!alreadyLoadedPaths.add(configKey.getAbsolutePathString())) { return ConfigFactory.empty(); } Config initialConfig = this.getOwnConfig(configKey); if (configKey.isRootPath()) { return initialConfig; } List<ConfigKeyPath> ownImports = this.topology.getOwnImports(configKey, runtimeConfig); // merge with other configs from imports if (ownImports != null) { for (ConfigKeyPath p : ownImports) { initialConfig = initialConfig.withFallback(this.getResolvedConfigRecursive(p, alreadyLoadedPaths, runtimeConfig)); } } // merge with configs from parent for Non root initialConfig = initialConfig .withFallback(this.getResolvedConfigRecursive(configKey.getParent(), alreadyLoadedPaths, runtimeConfig)); return initialConfig; }
Assert.assertEquals(it.next(), tag2); Assert.assertEquals(it.next(), tag); Assert.assertTrue(it.next().isRootPath()); Assert.assertEquals(it.next(), highPriorityTag);
public static boolean isAncestorOrSame(ConfigKeyPath descendant, ConfigKeyPath ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (descendant.equals(ancestor)) return true; if (descendant.isRootPath()) return false; return isAncestorOrSame(descendant.getParent(), ancestor); }
public List<ConfigKeyPath> getImportsRecursively(ConfigKeyPath configKey, Optional<Config> runtimeConfig) { return new ImportTraverser<>(key -> { if (key.isRootPath()) { return new LinkedList<>(); } List<ConfigKeyPath> imports = Lists.newArrayList(); imports.addAll(Lists.reverse(getOwnImports(key, runtimeConfig))); imports.add(key.getParent()); return imports; }, this.recursiveImportMap).traverseGraphRecursively(configKey); }
if (configKeyPath.isRootPath()) { return storeRoot;
@Override public String getAbsolutePathString() { if (this.isRootPath()) { return this.getOwnPathName() + PATH_DELIMETER; } // first level children do not need to add "/" if (this.parent.isRootPath()) return this.parent.getAbsolutePathString() + this.ownName; return this.parent.getAbsolutePathString() + PATH_DELIMETER + this.ownName; }
private Config getResolvedConfigRecursive(ConfigKeyPath configKey, Set<String> alreadyLoadedPaths, Optional<Config> runtimeConfig) { if (this.cs instanceof ConfigStoreWithResolution) { return ((ConfigStoreWithResolution) this.cs).getResolvedConfig(configKey, this.version); } if (!alreadyLoadedPaths.add(configKey.getAbsolutePathString())) { return ConfigFactory.empty(); } Config initialConfig = this.getOwnConfig(configKey); if (configKey.isRootPath()) { return initialConfig; } List<ConfigKeyPath> ownImports = this.topology.getOwnImports(configKey, runtimeConfig); // merge with other configs from imports if (ownImports != null) { for (ConfigKeyPath p : ownImports) { initialConfig = initialConfig.withFallback(this.getResolvedConfigRecursive(p, alreadyLoadedPaths, runtimeConfig)); } } // merge with configs from parent for Non root initialConfig = initialConfig .withFallback(this.getResolvedConfigRecursive(configKey.getParent(), alreadyLoadedPaths, runtimeConfig)); return initialConfig; }