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%2FSchemaAwareApplyOperation.java;h=ad2e60b379bb2ed4d283fce10cd0813a0f12fd77;hb=11d15938d7d4a0a6558a17fac0dea962ee709d68;hp=b691f9f20a2146769ea6f1fbd84e39aa4aa5c0b2;hpb=70388c194b80c4b17fdf86eba32862f9cfec9d69;p=yangtools.git diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java index b691f9f20a..ad2e60b379 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java @@ -53,8 +53,8 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, final AugmentationTarget augSchemas, final AugmentationIdentifier identifier) { - for (AugmentationSchema potential : augSchemas.getAvailableAugmentations()) { - for (DataSchemaNode child : potential.getChildNodes()) { + for (final AugmentationSchema potential : augSchemas.getAvailableAugmentations()) { + for (final DataSchemaNode child : potential.getChildNodes()) { if (identifier.getPossibleChildNames().contains(child.getQName())) { return new AugmentationModificationStrategy(potential, resolvedTree); } @@ -72,26 +72,29 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { } private static SchemaAwareApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode) { - List keyDefinition = schemaNode.getKeyDefinition(); + final List keyDefinition = schemaNode.getKeyDefinition(); + final SchemaAwareApplyOperation op; if (keyDefinition == null || keyDefinition.isEmpty()) { - return new UnkeyedListModificationStrategy(schemaNode); - } - if (schemaNode.isUserOrdered()) { - return new OrderedMapModificationStrategy(schemaNode); + op = new UnkeyedListModificationStrategy(schemaNode); + } else if (schemaNode.isUserOrdered()) { + op = new OrderedMapModificationStrategy(schemaNode); + } else { + op = new UnorderedMapModificationStrategy(schemaNode); } - - return new UnorderedMapModificationStrategy(schemaNode); + return MinMaxElementsValidation.from(op, schemaNode); } private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode) { + final SchemaAwareApplyOperation op; if(schemaNode.isUserOrdered()) { - return new OrderedLeafSetModificationStrategy(schemaNode); + op = new OrderedLeafSetModificationStrategy(schemaNode); } else { - return new UnorderedLeafSetModificationStrategy(schemaNode); + op = new UnorderedLeafSetModificationStrategy(schemaNode); } + return MinMaxElementsValidation.from(op, schemaNode); } - private static final void checkNotConflicting(final YangInstanceIdentifier path, final TreeNode original, final TreeNode current) throws ConflictingModificationAppliedException { + protected static final void checkNotConflicting(final YangInstanceIdentifier path, final TreeNode original, final TreeNode current) throws ConflictingModificationAppliedException { checkConflicting(path, original.getVersion().equals(current.getVersion()), "Node was replaced by other transaction."); checkConflicting(path, original.getSubtreeVersion().equals(current.getSubtreeVersion()), @@ -99,7 +102,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { } protected final ModificationApplyOperation resolveChildOperation(final PathArgument child) { - Optional potential = getChild(child); + final Optional potential = getChild(child); Preconditions.checkArgument(potential.isPresent(), "Operation for child %s is not defined.", child); return potential.get(); } @@ -134,7 +137,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { } protected void checkMergeApplicable(final YangInstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { - Optional original = modification.getOriginal(); + final Optional original = modification.getOriginal(); if (original.isPresent() && current.isPresent()) { /* * We need to do conflict detection only and only if the value of leaf changed @@ -160,7 +163,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { */ protected void checkWriteApplicable(final YangInstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { - Optional original = modification.getOriginal(); + final Optional original = modification.getOriginal(); if (original.isPresent() && current.isPresent()) { checkNotConflicting(path, original.get(), current.get()); } else if(original.isPresent()) { @@ -191,7 +194,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { case TOUCH: Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification", modification); - return modification.setSnapshot(Optional.of(applySubtreeChange(modification, currentMeta.get(), + return modification.setSnapshot(Optional.of(applyTouch(modification, currentMeta.get(), version))); case MERGE: final TreeNode result; @@ -240,7 +243,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation { * @param version New subtree version of parent node * @return A sealed TreeNode representing applied operation. */ - protected abstract TreeNode applySubtreeChange(ModifiedNode modification, TreeNode currentMeta, Version version); + protected abstract TreeNode applyTouch(ModifiedNode modification, TreeNode currentMeta, Version version); /** *