X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2Fschema%2Ftree%2FModificationApplyOperation.java;h=75d4ae93f0fadaf6f22ba5dc9a8b98a86b74ce50;hb=35fed4fb3caf6a7462f680de806389701d78bd6c;hp=59d0d28133222850dbf7a58c9f3e27f14e55837f;hpb=a6ea70c09b13489918c387d54cde8f1095721acc;p=yangtools.git
diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationApplyOperation.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationApplyOperation.java
index 59d0d28133..75d4ae93f0 100644
--- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationApplyOperation.java
+++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationApplyOperation.java
@@ -7,8 +7,9 @@
*/
package org.opendaylight.yangtools.yang.data.impl.schema.tree;
-import com.google.common.base.Optional;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+import java.util.Optional;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
@@ -17,26 +18,29 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
/**
- * Operation responsible for applying {@link ModifiedNode} on tree.
- *
- *
- * Operation is composite - operation on top level node consists of
- * suboperations on child nodes. This allows to walk operation hierarchy and
+ * An operation responsible for applying {@link ModifiedNode} on tree. The operation is a hierachical composite -
+ * the operation on top level node consists of suboperations on child nodes. This allows to walk operation hierarchy and
* invoke suboperations independently.
*
*
* Implementation notes
*
- * -
- * Implementations MUST expose all nested suboperations which operates on child
- * nodes expose via {@link #getChild(PathArgument)} method.
- *
- Same suboperations SHOULD be used when invoked via
- * {@link #apply(ModifiedNode, Optional, Version)} if applicable.
+ *
- Implementations MUST expose all nested suboperations which operates on child nodes expose via
+ * {@link #getChild(PathArgument)} method.
+ * - Same suboperations SHOULD be used when invoked via {@link #apply(ModifiedNode, Optional, Version)},
+ * if applicable.
+ * - There are exactly two base implementations:
+ *
+ * - {@link SchemaAwareApplyOperation}, which serves as the base class for stateful mutators -- directly
+ * impacting the layout and transitions of the {@link TreeNode} hierarchy.
+ *
- {@link AbstractValidation}, which serves as the base class for stateless checks, which work purely on top
+ * of the {@link TreeNode} hierarchy. These are always overlaid on top of some other
+ * {@link ModificationApplyOperation}, ultimately leading to a {@link SchemaAwareApplyOperation}.
+ *
+ * This allows baseline invocations from {@link OperationWithModification} to be bimorphic in the first line of
+ * dispatch.
+ *
*
- *
- *
- * Hierarchical composite operation which is responsible for applying
- * modification on particular subtree and creating updated subtree
*/
abstract class ModificationApplyOperation implements StoreTreeNode {
/**
@@ -55,29 +59,41 @@ abstract class ModificationApplyOperation implements StoreTreeNode apply(ModifiedNode modification, Optional storeMeta, Version version);
+ abstract Optional extends TreeNode> apply(ModifiedNode modification, Optional extends TreeNode> storeMeta,
+ Version version);
/**
* Checks if provided node modification could be applied to current metadata node.
*
+ * @param path Path to modification
* @param modification Modification
* @param current Metadata Node to which modification should be applied
* @param version Metadata version
* @throws DataValidationFailedException if the modification is not applicable
*/
- abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification,
- Optional current, Version version) throws DataValidationFailedException;
+ abstract void checkApplicable(ModificationPath path, NodeModification modification,
+ Optional extends TreeNode> current, Version version) throws DataValidationFailedException;
+
+ /**
+ * Performs a quick structural verification of NodeModification, such as written values / types uses right
+ * structural elements.
+ *
+ * @param modification data to be verified.
+ * @throws IllegalArgumentException If provided NodeModification does not adhere to the
+ * structure.
+ */
+ abstract void quickVerifyStructure(NormalizedNode, ?> modification);
/**
- * Performs structural verification of NodeModification, such as writen values / types uses
- * right structural elements.
+ * Performs a full structural verification of NodeModification, such as written values / types uses right
+ * structural elements. Unlike {@link #quickVerifyStructure(NormalizedNode)} this includes recursively checking
+ * children, too.
*
* @param modification data to be verified.
- * @param verifyChildren true if structure verification should be run against children.
* @throws IllegalArgumentException If provided NodeModification does not adhere to the
* structure.
*/
- abstract void verifyStructure(NormalizedNode, ?> modification, boolean verifyChildren);
+ abstract void fullVerifyStructure(NormalizedNode, ?> modification);
/**
* Return the tracking policy for this node's children.
@@ -100,11 +116,18 @@ abstract class ModificationApplyOperation implements StoreTreeNode getChild(PathArgument child);
abstract void recursivelyVerifyStructure(NormalizedNode, ?> value);
+
+ abstract ToStringHelper addToStringAttributes(ToStringHelper helper);
+
+ @Override
+ public final String toString() {
+ return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+ }
}