SchemaAwareApplyOperation has getSchema()
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / SchemaAwareApplyOperation.java
index 56ca5b69a0d7f8802631b218c6a641f4190bc183..3baed737a8289e8364d7fe4b47c193117de022f2 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.base.Verify.verifyNotNull;
 
 import java.util.List;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -30,13 +31,14 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
+abstract class SchemaAwareApplyOperation<T extends WithStatus> extends ModificationApplyOperation {
     private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareApplyOperation.class);
 
     public static ModificationApplyOperation from(final DataSchemaNode schemaNode,
@@ -59,7 +61,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
         throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass());
     }
 
-    public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree,
+    public static AugmentationModificationStrategy from(final DataNodeContainer resolvedTree,
             final AugmentationTarget augSchemas, final AugmentationIdentifier identifier,
             final DataTreeConfiguration treeConfig) {
         for (final AugmentationSchemaNode potential : augSchemas.getAvailableAugmentations()) {
@@ -83,7 +85,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     private static ModificationApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode,
             final DataTreeConfiguration treeConfig) {
         final List<QName> keyDefinition = schemaNode.getKeyDefinition();
-        final SchemaAwareApplyOperation op;
+        final SchemaAwareApplyOperation<?> op;
         if (keyDefinition == null || keyDefinition.isEmpty()) {
             op = new UnkeyedListModificationStrategy(schemaNode, treeConfig);
         } else {
@@ -290,6 +292,12 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     protected abstract void checkTouchApplicable(ModificationPath path, NodeModification modification,
             Optional<TreeNode> current, Version version) throws DataValidationFailedException;
 
+    /**
+     * Return the {@link WithStatus}-subclass schema associated with this operation.
+     * @return A model node
+     */
+    abstract @NonNull T getSchema();
+
     /**
      * Checks if supplied schema node belong to specified Data Tree type. All nodes belong to the operational tree,
      * nodes in configuration tree are marked as such.