import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.SchemaTreeInference;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
/**
public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
final EffectiveModelContext schemaContext) {
super(writer);
- this.root = this.schemaContext = requireNonNull(schemaContext);
+ root = this.schemaContext = requireNonNull(schemaContext);
}
- /**
- * Create a new writer backed by a {@link NormalizedNodeStreamWriter}.
- *
- * @param writer Back-end writer
- * @param schemaContext Associated {@link EffectiveModelContext}
- * @param path root path
- */
- public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
- final EffectiveModelContext schemaContext, final SchemaPath path) {
+ private SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
+ final SchemaInferenceStack stack) {
super(writer);
- this.schemaContext = requireNonNull(schemaContext);
+ schemaContext = stack.getEffectiveModelContext();
- final SchemaInferenceStack stack = SchemaInferenceStack.ofSchemaPath(schemaContext, path);
if (!stack.isEmpty()) {
final EffectiveStatement<?, ?> current = stack.currentStatement();
// FIXME: this should be one of NormalizedNodeContainer/NotificationDefinition/OperationDefinition
}
}
+ /**
+ * Create a new writer backed by a {@link NormalizedNodeStreamWriter}.
+ *
+ * @param writer Back-end writer
+ * @param schemaContext Associated {@link EffectiveModelContext}
+ * @param path root path
+ */
+ public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
+ final EffectiveModelContext schemaContext, final Absolute path) {
+ this(writer, SchemaInferenceStack.of(schemaContext, path));
+ }
+
+ /**
+ * Create a new writer backed by a {@link NormalizedNodeStreamWriter}.
+ *
+ * @param writer Back-end writer
+ * @param rootInference A SchemaTreeInference pointing to the root element
+ */
+ public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
+ final SchemaTreeInference rootInference) {
+ this(writer, SchemaInferenceStack.ofInference(rootInference));
+ }
+
+ /**
+ * Create a new writer backed by a {@link NormalizedNodeStreamWriter}.
+ *
+ * @param writer Back-end writer
+ * @param schemaContext Associated {@link EffectiveModelContext}
+ * @param path root path
+ * @deprecated Use either one of the alternative constructors instead.
+ */
+ @Deprecated(since = "7.0.11")
+ public SchemaOrderedNormalizedNodeWriter(final NormalizedNodeStreamWriter writer,
+ final EffectiveModelContext schemaContext, final SchemaPath path) {
+ this(writer, SchemaInferenceStack.ofSchemaPath(schemaContext, path));
+ }
+
@Override
public SchemaOrderedNormalizedNodeWriter write(final NormalizedNode node) throws IOException {
if (schemaContext.equals(root)) {
* Sets current schema node new value and store old value for later restore.
*/
SchemaNodeSetter(final SchemaNode schemaNode) {
- previousSchemaNode = SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode;
- SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode = schemaNode;
+ previousSchemaNode = currentSchemaNode;
+ currentSchemaNode = schemaNode;
}
/**
*/
@Override
public void close() {
- SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode = previousSchemaNode;
+ currentSchemaNode = previousSchemaNode;
}
}
}