+ setEffectiveModelContext(schemaContext);
+ }
+ }
+
+ InMemoryDataTree(final TreeNode rootNode, final DataTreeConfiguration treeConfig,
+ final EffectiveModelContext schemaContext, final DataSchemaNode rootSchemaNode,
+ final boolean maskMandatory) {
+ this.treeConfig = requireNonNull(treeConfig, "treeConfig");
+ this.maskMandatory = maskMandatory;
+
+ state = DataTreeState.createInitial(rootNode).withSchemaContext(schemaContext, getOperation(rootSchemaNode));
+ }
+
+ private ModificationApplyOperation getOperation(final DataSchemaNode rootSchemaNode) {
+ if (rootSchemaNode instanceof ContainerLike && maskMandatory) {
+ return new ContainerModificationStrategy((ContainerLike) rootSchemaNode, treeConfig);
+ }
+ if (rootSchemaNode instanceof ListSchemaNode) {
+ final PathArgument arg = treeConfig.getRootPath().getLastPathArgument();
+ if (arg instanceof NodeIdentifierWithPredicates) {
+ return maskMandatory ? new MapEntryModificationStrategy((ListSchemaNode) rootSchemaNode, treeConfig)
+ : MapEntryModificationStrategy.of((ListSchemaNode) rootSchemaNode, treeConfig);
+ }
+ }
+
+ try {
+ return SchemaAwareApplyOperation.from(rootSchemaNode, treeConfig);
+ } catch (ExcludedDataSchemaNodeException e) {
+ throw new IllegalArgumentException("Root node does not belong current data tree", e);