/** * Traverse the graph starting at the provided node. * @param startingNode starting node. * @return a List containing the DFS traversal starting at the node. * @throws CircularDependencyException if there is a circular dependency in the loaded traversal. */ List<T> traverseGraphRecursively(T startingNode) { return doTraverseGraphRecursively(startingNode, new NodePath<>(startingNode)); }
/** * Add a sub-traversal for a neighboring node. */ private void addSubtraversal(T node, LinkedList<T> imports, Set<T> alreadyIncludedImports, NodePath<T> nodePath) throws ExecutionException { if (addNodeIfNotAlreadyIncluded(node, imports, alreadyIncludedImports)) { for (T inheritedFromParent : doTraverseGraphRecursively(node, nodePath)) { addNodeIfNotAlreadyIncluded(inheritedFromParent, imports, alreadyIncludedImports); } } }
@Override public Config call() { return InMemoryValueInspector.this.valueFallback.getOwnConfig(configKey); } });
private void testValuesForEspressoTag(ConfigStoreValueInspector valueInspector){ Config config = valueInspector.getOwnConfig(this.espressoTag); testValuesForEspressoTagOwnConfig(config); config = valueInspector.getResolvedConfig(this.espressoTag); testValuesForEspressoTagResolvedConfig(config); }
private void testValuesForIdentity(ConfigStoreValueInspector valueInspector){ Config ownConfig = valueInspector.getOwnConfig(identity); checkValuesForIdentityOwnConfig(ownConfig); Config resolvedConfig = valueInspector.getResolvedConfig(identity); checkValuesForIdentityResolvedConfig(resolvedConfig); }
public Collection<ConfigKeyPath> getImportedByRecursively(ConfigKeyPath configKey, Optional<Config> runtimeConfig) { return new ImportTraverser<>(key -> Lists.newLinkedList(getImportedBy(key, runtimeConfig)), this.recursiveImportedByMap).traverseGraphRecursively(configKey); } }
@Override public Config call() { return InMemoryValueInspector.this.valueFallback.getResolvedConfig(configKey, runtimeConfig); } });
@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 List<T> doTraverseGraphRecursively(T node, NodePath<T> nodePath) { try { return this.traversalCache.get(node, () -> computeRecursiveTraversal(node, nodePath)); } catch (ExecutionException | UncheckedExecutionException ee) { throw unpackExecutionException(ee); } }
public void appendNode(T node) { if (this.nodesSet.contains(node)) { throw new CircularDependencyException("Found cycle in traversal: " + computePath(node)); } this.nodesSet.add(node); this.nodesList.add(node); }
@Override public String toString() { return this.getAbsolutePathString(); }
/** * {@inheritDoc}. * * <p> * If the result is already in cache, return the result. * Otherwise, delegate the functionality to the fallback object * </p> */ @Override public List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey) { return getOwnImports(configKey, Optional.<Config>absent()); }
@Override public Config getResolvedConfig(ConfigKeyPath configKey) { return getResolvedConfig(configKey, Optional.<Config>absent()); }
/** * {@inheritDoc}. * * <p> * This implementation simply delegate the functionality to the internal {@link ConfigStore}/version if * the internal {@link ConfigStore} is {@link ConfigStoreWithResolution}, otherwise throws {@link UnsupportedOperationException} * </p> */ @Override public List<ConfigKeyPath> getImportsRecursively(ConfigKeyPath configKey) { return getImportsRecursively(configKey, Optional.<Config>absent()); }
@Override public ConfigKeyPath getParent() { if (this.isRootPath()) throw new UnsupportedOperationException("Can not getParent from Root"); return this.parent; }
/** * {@inheritDoc}. * * <p> * This implementation simply delegate the functionality to the internal {@link ConfigStore}/version if * the internal {@link ConfigStore} is {@link ConfigStoreWithImportedBy}, otherwise throws {@link UnsupportedOperationException} * </p> */ @Override public Collection<ConfigKeyPath> getImportedBy(ConfigKeyPath configKey) { return getImportedBy(configKey, Optional.<Config>absent()); }
/** * {@inheritDoc}. * * <p> * This implementation simply delegate the functionality to the internal {@link ConfigStore}/version if * the internal {@link ConfigStore} is {@link ConfigStoreWithImportedByRecursively}, otherwise throws {@link UnsupportedOperationException} * </p> */ @Override public Collection<ConfigKeyPath> getImportedByRecursively(ConfigKeyPath configKey) { return getImportedByRecursively(configKey, Optional.<Config>absent()); }
/** * {@inheritDoc}. * * <p> * If present in the cache, return the cached {@link com.typesafe.config.Config} for given input * Otherwise, simply delegate the functionality to the internal {ConfigStoreValueInspector} and store the value into cache * </p> */ @Override public Config getResolvedConfig(final ConfigKeyPath configKey) { return getResolvedConfig(configKey, Optional.<Config>absent()); }
/** * {@inheritDoc}. * * <p> * This implementation simply delegate the functionality to the internal {@link ConfigStore}/version * </p> */ @Override public List<ConfigKeyPath> getOwnImports(ConfigKeyPath configKey) { return getOwnImports(configKey, Optional.<Config>absent()); }
@Test(expectedExceptions = java.lang.UnsupportedOperationException.class) public void testGetParentOfRoot() { SingleLinkedListConfigKeyPath.ROOT.getParent(); }