- if (maskMandatory && rootSchemaNode instanceof ContainerSchemaNode) {
- return new ContainerModificationStrategy((ContainerSchemaNode) rootSchemaNode, treeConfig);
+ 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);