sergey-chugunov-1985 commented on a change in pull request #72:
URL: https://github.com/apache/ignite-3/pull/72#discussion_r599465132
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/configuration/ConfigurationRegistry.java
##########
@@ -71,6 +80,39 @@ public void registerStorage(ConfigurationStorage
configurationStorage) {
return (T)configs.get(rootKey.key());
}
+ /**
+ * Convert configuration subtree into a user-defined representation.
+ *
+ * @param path Path to configuration subtree. Can be empty, can't be
{@code null}.
+ * @param visitor Visitor that will be applied to the subtree and build
the representation.
+ * @param <T> Type of the representation.
+ * @return User-defined representation constructed by {@code visitor}.
+ * @throws IllegalArgumentException If {@code path} is not found in
current configuration.
+ */
+ public <T> T represent(List<String> path, ConfigurationVisitor<T> visitor)
throws IllegalArgumentException {
+ SuperRoot mergedSuperRoot = changer.mergedSuperRoot();
+
+ Object node;
+ try {
+ node = ConfigurationUtil.find(path, mergedSuperRoot);
+ }
+ catch (KeyNotFoundException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+
+ if (node instanceof TraversableTreeNode)
+ return ((TraversableTreeNode)node).accept(null, visitor);
+
+ assert node == null || node instanceof Serializable;
Review comment:
how can we get a null node here? if it is not found, we'll throw an
exception, what is the other scenario?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]