super(writer);
this.schemaContext = requireNonNull(schemaContext);
- final SchemaInferenceStack stack = SchemaInferenceStack.ofInstantiatedPath(schemaContext, path);
+ final SchemaInferenceStack stack = SchemaInferenceStack.ofSchemaPath(schemaContext, path);
if (!stack.isEmpty()) {
final EffectiveStatement<?, ?> current = stack.currentStatement();
// FIXME: this should be one of NormalizedNodeContainer/NotificationDefinition/OperationDefinition
SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode = previousSchemaNode;
}
}
-}
\ No newline at end of file
+}
/**
* Create a new stack backed by an effective model, pointing to specified schema node identified by an absolute
- * {@link SchemaPath} and its {@link SchemaPath#getPathFromRoot()}.
+ * {@link SchemaPath} and its {@link SchemaPath#getPathFromRoot()} interpreted as a schema node identifier.
*
* @param effectiveModel EffectiveModelContext to which this stack is attached
* @return A new stack
return ret;
}
+ /**
+ * Create a new stack backed by an effective model, pointing to specified schema node identified by an absolute
+ * {@link SchemaPath} and its {@link SchemaPath#getPathFromRoot()}, interpreted as a series of steps along primarily
+ * schema tree, with grouping namespace being the alternative lookup.
+ *
+ * @param effectiveModel EffectiveModelContext to which this stack is attached
+ * @return A new stack
+ * @throws NullPointerException {@code effectiveModel} is null
+ * @throws IllegalArgumentException if {@code path} cannot be resolved in the effective model or if it is not an
+ * absolute path.
+ */
+ @Deprecated
+ public static @NonNull SchemaInferenceStack ofSchemaPath(final EffectiveModelContext effectiveModel,
+ final SchemaPath path) {
+ checkArgument(path.isAbsolute(), "Cannot operate on relative path %s", path);
+ final SchemaInferenceStack ret = new SchemaInferenceStack(effectiveModel);
+
+ for (QName step : path.getPathFromRoot()) {
+ try {
+ ret.enterSchemaTree(step);
+ } catch (IllegalArgumentException schemaEx) {
+ try {
+ ret.enterGrouping(step);
+ } catch (IllegalArgumentException ex) {
+ ex.addSuppressed(schemaEx);
+ throw ex;
+ }
+ }
+ }
+
+ return ret;
+ }
+
@Override
public EffectiveModelContext getEffectiveModelContext() {
return effectiveModel;