Sharpen SchemaAwareApplyOperation.getSchema() 42/106442/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 12 Jun 2023 12:22:01 +0000 (14:22 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 12 Jun 2023 12:25:35 +0000 (14:25 +0200)
Since we do not have AugmentationNode, we have lost the only strategy
which did not rely on DataSchemaNode (and necessitated
DocumentedNode.WithStatus as the base schema). Sharpen the contract so
we can rely on DataSchemaNode's interface.

Change-Id: Ia9dda657be1ad61ff818203430424819cab7a20c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/AbstractNodeContainerModificationStrategy.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/DataNodeContainerModificationStrategy.java
data/yang-data-tree-ri/src/main/java/org/opendaylight/yangtools/yang/data/tree/impl/SchemaAwareApplyOperation.java

index ff34ba171af3f8d67e5fe112172a90023ba83279..a0d6daeac92774d03f4af1815eb8c6d80bb1af6a 100644 (file)
@@ -32,11 +32,11 @@ import org.opendaylight.yangtools.yang.data.tree.api.TreeType;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.MutableTreeNode;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
 import org.opendaylight.yangtools.yang.data.tree.impl.node.Version;
-import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
-abstract class AbstractNodeContainerModificationStrategy<T extends WithStatus>
+abstract class AbstractNodeContainerModificationStrategy<T extends DataSchemaNode>
         extends SchemaAwareApplyOperation<T> {
-    abstract static class Invisible<T extends WithStatus> extends AbstractNodeContainerModificationStrategy<T> {
+    abstract static class Invisible<T extends DataSchemaNode> extends AbstractNodeContainerModificationStrategy<T> {
         private final @NonNull SchemaAwareApplyOperation<T> entryStrategy;
 
         Invisible(final NormalizedNodeContainerSupport<?, ?> support, final DataTreeConfiguration treeConfig,
@@ -60,11 +60,11 @@ abstract class AbstractNodeContainerModificationStrategy<T extends WithStatus>
         }
     }
 
-    abstract static class Visible<T extends WithStatus> extends AbstractNodeContainerModificationStrategy<T> {
+    abstract static class Visible<T extends DataSchemaNode> extends AbstractNodeContainerModificationStrategy<T> {
         private final @NonNull T schema;
 
         Visible(final NormalizedNodeContainerSupport<?, ?> support, final DataTreeConfiguration treeConfig,
-            final T schema) {
+                final T schema) {
             super(support, treeConfig);
             this.schema = requireNonNull(schema);
         }
index ac653baf234db34ad7b93b502cdb05e80a5e648b..ae29c3e83508829fba320a954f73350b609532cf 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.impl.AbstractNodeContainerModificationStrategy.Visible;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
-import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
  *
  * @param <T> Type of the container node
  */
-class DataNodeContainerModificationStrategy<T extends DataNodeContainer & WithStatus> extends Visible<T> {
+class DataNodeContainerModificationStrategy<T extends DataSchemaNode & DataNodeContainer> extends Visible<T> {
     private static final Logger LOG = LoggerFactory.getLogger(DataNodeContainerModificationStrategy.class);
     private static final VarHandle CHILDREN;
 
@@ -65,7 +65,7 @@ class DataNodeContainerModificationStrategy<T extends DataNodeContainer & WithSt
     }
 
     private ModificationApplyOperation resolveChild(final PathArgument identifier) {
-        final T schema = getSchema();
+        final var schema = getSchema();
         final var qname = identifier.getNodeType();
         final var child = schema.dataChildByName(qname);
         if (child == null) {
index 9052f8a1aa1450e4e4e5e61973314ff1e0fa0411..8be123f28c0cbb33ff8664b8d07e2acd1cd4f371 100644 (file)
@@ -31,7 +31,6 @@ import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.DocumentedNode.WithStatus;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
@@ -39,7 +38,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class SchemaAwareApplyOperation<T extends WithStatus> extends ModificationApplyOperation {
+abstract class SchemaAwareApplyOperation<T extends DataSchemaNode> extends ModificationApplyOperation {
     private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareApplyOperation.class);
 
     static ModificationApplyOperation from(final DataSchemaNode schemaNode,
@@ -277,7 +276,8 @@ abstract class SchemaAwareApplyOperation<T extends WithStatus> extends Modificat
             Optional<? extends TreeNode> current, Version version) throws DataValidationFailedException;
 
     /**
-     * Return the {@link WithStatus}-subclass schema associated with this operation.
+     * Return the {@link DataSchemaNode}-subclass schema associated with this operation.
+     *
      * @return A model node
      */
     abstract @NonNull T getSchema();