sashapolo commented on a change in pull request #244:
URL: https://github.com/apache/ignite-3/pull/244#discussion_r681806418
##########
File path:
modules/configuration/src/main/java/org/apache/ignite/internal/configuration/tree/NamedListNode.java
##########
@@ -222,20 +338,62 @@ public void reorderKeys(List<String> orderedKeys) {
/** {@inheritDoc} */
@Override public void construct(String key, ConfigurationSource src) {
if (src == null)
- map.put(key, null);
- else {
- N val = map.get(key);
-
- val = val == null ? valSupplier.get() : (N)val.copy();
-
- map.put(key, val);
-
- src.descend(val);
- }
+ delete(key);
+ else
+ createOrUpdate(key, src::descend);
}
/** {@inheritDoc} */
@Override public NamedListNode<N> copy() {
return new NamedListNode<>(this);
}
+
+ /**
+ * Descriptor for internal named list element representation. Has node
itself and its internal id.
+ *
+ * @param <N> Type of the node.
+ */
+ private static class ElementDescriptor<N extends InnerNode> implements
Cloneable {
+ /** Element's internal id. */
+ public String internalId;
+
+ /** Element node value. */
+ public N value;
+
+ /**
+ * Constructor.
+ *
+ * @param value Node instance.
+ */
+ ElementDescriptor(N value) {
+ this.value = value;
+ internalId = UUID.randomUUID().toString().replace("-", "");
+ }
+
+ /**
+ * Private constructor with entire fields list.
+ *
+ * @param internalId Internal id.
+ * @param value Node instance.
+ */
+ private ElementDescriptor(String internalId, N value) {
+ this.internalId = internalId;
+ this.value = value;
+ }
+
+ /**
+ * Makes a copy of the element descriptor. Not to be confused with
{@link #clone()}.
+ *
+ * @return New instance with the same internal id but copied node
instance.
+ * @see InnerNode#copy()
+ */
+ public ElementDescriptor<N> copy() {
+ return new ElementDescriptor<>(internalId, (N)value.copy());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected ElementDescriptor<N> clone() {
Review comment:
I, personally, have very little experience with `clone`, its usage is
even discouraged in some books and code styles. For me, `copy` and
`shallowCopy` are much more descriptive names, than `copy` and `clone`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]