zstan commented on code in PR #6276:
URL: https://github.com/apache/ignite-3/pull/6276#discussion_r2218276806


##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -185,11 +193,17 @@ void addChildNodes(ConfigNode... childNodes) {
     }
 
     /**
-     * Returns {@code true} if this node is a root node, {@code false} 
otherwise.
+     * Add a polymorhic child node to this node.
      */
-    @JsonIgnore
-    public boolean isRoot() {
-        return parent == null;
+    void addPolymorhicNode(String name, Map<String, ConfigNode> childNodes) {

Review Comment:
   ```suggestion
       void addPolymorphicNode(String name, Map<String, ConfigNode> childNodes) 
{
   ```



##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -173,7 +181,7 @@ public Collection<ConfigNode> childNodes() {
     void addChildNodes(Collection<ConfigNode> childNodes) {
         assert !flags.contains(Flags.IS_VALUE) : "Value node can't have 
children.";
 
-        childNodes.forEach(e -> childNodeMap.put(e.name(), e));
+        childNodes.forEach(e -> childNodeMap.put(e.name(), new Node(e)));

Review Comment:
   do it need to be checked that childNode is not rewritten ? i.e. 
childNodeMap.put return null for each insertion here ?



##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -185,11 +193,17 @@ void addChildNodes(ConfigNode... childNodes) {
     }
 
     /**
-     * Returns {@code true} if this node is a root node, {@code false} 
otherwise.
+     * Add a polymorhic child node to this node.
      */
-    @JsonIgnore
-    public boolean isRoot() {
-        return parent == null;
+    void addPolymorhicNode(String name, Map<String, ConfigNode> childNodes) {
+        boolean nameMatches = childNodes.values().stream().allMatch(n -> 
n.name().equals(name));
+        if (!nameMatches) {
+            throw new IllegalArgumentException("All nodes name should be equal 
to " + name);

Review Comment:
   ```suggestion
               throw new IllegalArgumentException("All nodes name should be 
equal to: " + name);
   ```



##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -350,5 +387,110 @@ static class Attributes {
         static String NAME = "name";
         static String KIND = "kind";
         static String CLASS = "class";
+        static String INSTANCE_TYPE = "instanceType";
+    }
+
+    /**
+     * Node holds a references either to a single node or to a map of possible 
polymorphic nodes with extra `base` node that 
+     * includes fields common to all polymorphic instances. Each polymorphic 
node has child nodes that represent its fields 
+     * and fields common to its polymorphic configuration as well.
+     */
+    public static class Node {
+        /**
+         * Instance type for a node that represents a `base` class of a 
polymorphic node. 
+         * A base node includes fields common to all polymorphic instances.
+         */
+        static final String BASE_INSTANCE_TYPE = "";
+
+        /**
+         * Non-polymorphic node.
+         */
+        @JsonProperty
+        private ConfigNode single;

Review Comment:
   ```suggestion
           private @Nullable ConfigNode single;
   ```



##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -350,5 +387,110 @@ static class Attributes {
         static String NAME = "name";
         static String KIND = "kind";
         static String CLASS = "class";
+        static String INSTANCE_TYPE = "instanceType";
+    }
+
+    /**
+     * Node holds a references either to a single node or to a map of possible 
polymorphic nodes with extra `base` node that 
+     * includes fields common to all polymorphic instances. Each polymorphic 
node has child nodes that represent its fields 
+     * and fields common to its polymorphic configuration as well.
+     */
+    public static class Node {
+        /**
+         * Instance type for a node that represents a `base` class of a 
polymorphic node. 
+         * A base node includes fields common to all polymorphic instances.
+         */
+        static final String BASE_INSTANCE_TYPE = "";
+
+        /**
+         * Non-polymorphic node.
+         */
+        @JsonProperty
+        private ConfigNode single;
+
+        /**
+         * All polymorphic instances.
+         */
+        @JsonProperty
+        private Map<String, ConfigNode> polymorphicNodes = new 
LinkedHashMap<>();
+
+        @SuppressWarnings("unused")
+        Node() {
+            // Default constructor for Jackson deserialization.
+        }
+
+        Node(ConfigNode single) {
+            this.single = single;
+            this.polymorphicNodes = null;
+        }
+
+        Node(Map<String, ConfigNode> polymorphicNodes) {
+            this.single = null;
+            this.polymorphicNodes = Map.copyOf(polymorphicNodes);
+        }
+
+        /**
+         * Returns {@code true} if this node represents a polymorphic 
configuration node.
+         */
+        @JsonIgnore
+        boolean isPolymorphic() {
+            return polymorphicNodes != null;
+        }
+
+        /**
+         * Returns a single node if this node presents one or throws.
+         */
+        ConfigNode node() {
+            assert !isPolymorphic() : "Use the nodes() method instead.";
+            return single;
+        }
+
+        /**
+         * Returns a map of polymorphic instances if this node presents one or 
throws.

Review Comment:
   presents one ? - is it correct ?



##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/compatibility/framework/ConfigNode.java:
##########
@@ -350,5 +387,110 @@ static class Attributes {
         static String NAME = "name";
         static String KIND = "kind";
         static String CLASS = "class";
+        static String INSTANCE_TYPE = "instanceType";
+    }
+
+    /**
+     * Node holds a references either to a single node or to a map of possible 
polymorphic nodes with extra `base` node that 
+     * includes fields common to all polymorphic instances. Each polymorphic 
node has child nodes that represent its fields 
+     * and fields common to its polymorphic configuration as well.
+     */
+    public static class Node {
+        /**
+         * Instance type for a node that represents a `base` class of a 
polymorphic node. 
+         * A base node includes fields common to all polymorphic instances.
+         */
+        static final String BASE_INSTANCE_TYPE = "";
+
+        /**
+         * Non-polymorphic node.
+         */
+        @JsonProperty
+        private ConfigNode single;
+
+        /**
+         * All polymorphic instances.
+         */
+        @JsonProperty
+        private Map<String, ConfigNode> polymorphicNodes = new 
LinkedHashMap<>();

Review Comment:
   ```suggestion
           private @Nullable Map<String, ConfigNode> polymorphicNodes = new 
LinkedHashMap<>();
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to