InMemoryDataTreeModification(final InMemoryDataTreeSnapshot snapshot, final RootModificationApplyOperation resolver) {
this.snapshot = Preconditions.checkNotNull(snapshot);
this.strategyTree = Preconditions.checkNotNull(resolver).snapshot();
- this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode());
+ this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode(), false);
/*
* We could allocate version beforehand, since Version contract
* states two allocated version must be allways different.
ModifiedNode modification = rootNode;
// We ensure strategy is present.
ModificationApplyOperation operation = resolveModificationStrategy(path);
+ boolean isOrdered = true;
+ if (operation instanceof SchemaAwareApplyOperation) {
+ isOrdered = ((SchemaAwareApplyOperation) operation).isOrdered();
+ }
+
for (PathArgument pathArg : path.getPathArguments()) {
- modification = modification.modifyChild(pathArg);
+ modification = modification.modifyChild(pathArg, isOrdered);
}
return OperationWithModification.from(operation, modification);
}
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
+import java.util.HashMap;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
}
};
- private final Map<PathArgument, ModifiedNode> children = new LinkedHashMap<>();
+ private final Map<PathArgument, ModifiedNode> children;
private final Optional<TreeNode> original;
private final PathArgument identifier;
private ModificationType modificationType = ModificationType.UNMODIFIED;
private Optional<TreeNode> snapshotCache;
private NormalizedNode<?, ?> value;
- private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original) {
+ private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original, boolean isOrdered) {
this.identifier = identifier;
this.original = original;
+
+ if (isOrdered) {
+ children = new LinkedHashMap<>();
+ } else {
+ children = new HashMap<>();
+ }
}
/**
* @return {@link org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ModifiedNode} for specified child, with {@link #getOriginal()}
* containing child metadata if child was present in original data.
*/
- public ModifiedNode modifyChild(final PathArgument child) {
+ public ModifiedNode modifyChild(final PathArgument child, boolean isOrdered) {
clearSnapshot();
if (modificationType == ModificationType.UNMODIFIED) {
updateModificationType(ModificationType.SUBTREE_MODIFIED);
currentMetadata = Optional.absent();
}
- ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata);
+ ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata, isOrdered);
children.put(child, newlyCreated);
return newlyCreated;
}
+ modificationType + ", childModification=" + children + "]";
}
- public static ModifiedNode createUnmodified(final TreeNode metadataTree) {
- return new ModifiedNode(metadataTree.getIdentifier(), Optional.of(metadataTree));
+ public static ModifiedNode createUnmodified(final TreeNode metadataTree, boolean isOrdered) {
+ return new ModifiedNode(metadataTree.getIdentifier(), Optional.of(metadataTree), isOrdered);
}
}
}
public OperationWithModification forChild(final PathArgument childId) {
- ModifiedNode childMod = modification.modifyChild(childId);
- Optional<ModificationApplyOperation> childOp = applyOperation.getChild(childId);
- return from(childOp.get(),childMod);
+ ModificationApplyOperation childOp = applyOperation.getChild(childId).get();
+ boolean isOrdered = true;
+ if (childOp instanceof SchemaAwareApplyOperation) {
+ isOrdered = ((SchemaAwareApplyOperation) childOp).isOrdered();
+ }
+ ModifiedNode childMod = modification.modifyChild(childId, isOrdered);
+
+ return from(childOp,childMod);
}
}