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=52e49d63e73b995ea10bbeefb62df9c6101b44c3;hp=83c9b6d0411c5146ba156a03a9f7376e9ebebffa;hpb=bed02b73ece35ca60ab377ae55c97ff9f6b6d44f;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 83c9b6d041..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,29 +18,33 @@ 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 *

*/ abstract class ModificationApplyOperation implements StoreTreeNode { /** - * - * Implementation of this operation must be stateless and must not change - * state of this object. + * Implementation of this operation must be stateless and must not change state of this object. * * @param modification * NodeModification to be applied @@ -47,40 +52,48 @@ abstract class ModificationApplyOperation implements StoreTreeNode apply(ModifiedNode modification, Optional storeMeta, Version version); + abstract Optional apply(ModifiedNode modification, Optional 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 - * @return true if modification is applicable - * false if modification is no applicable - * @throws DataValidationFailedException + * @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 current, Version version) throws DataValidationFailedException; /** + * Performs a quick structural verification of NodeModification, such as written values / types uses right + * structural elements. * - * Performs structural verification of NodeModification, such as writen 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 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) - throws IllegalArgumentException; + abstract void fullVerifyStructure(NormalizedNode modification); /** * Return the tracking policy for this node's children. @@ -101,13 +114,20 @@ abstract class ModificationApplyOperation implements StoreTreeNode value, Version version); /** - * Returns a suboperation for specified tree node + * Returns a suboperation for specified tree node. * - * @return Reference to suboperation for specified tree node, {@link Optional#absent()} - * if suboperation is not supported for specified tree node. + * @return Reference to suboperation for specified tree node, {@link Optional#empty()} + * if suboperation is not supported for specified tree node. */ @Override public abstract Optional getChild(PathArgument child); abstract void recursivelyVerifyStructure(NormalizedNode value); + + abstract ToStringHelper addToStringAttributes(ToStringHelper helper); + + @Override + public final String toString() { + return addToStringAttributes(MoreObjects.toStringHelper(this)).toString(); + } }