/**
* Interface representing a data tree which can be modified in an MVCC fashion.
*/
+// FIXME: 3.0.0: Consider splitting out a read-only interface, which has no means of affecting internal state
public interface DataTree extends DataTreeTip {
/**
* Take a read-only point-in-time snapshot of the tree.
package org.opendaylight.yangtools.yang.data.api.schema.tree;
import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
- * Read-only snapshot of a {@link DataTree}. The snapshot is stable and isolated,
- * e.g. data tree changes occurring after the snapshot has been taken are not
- * visible through the snapshot.
+ * Read-only snapshot of a {@link DataTree}. The snapshot is stable and isolated, e.g. data tree changes occurring after
+ * the snapshot has been taken are not visible through the snapshot.
*/
public interface DataTreeSnapshot {
/**
* @return A new data tree modification
*/
DataTreeModification newModification();
+
+ /**
+ * Return the current {@link SchemaContext}, which is being used for operations.
+ *
+ * @return Current schema context.
+ */
+ // FIXME: 3.0.0: Make this method non-default.
+ default @NonNull SchemaContext getSchemaContext() {
+ throw new UnsupportedOperationException("Not implemented by " + getClass());
+ }
}
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* A {@link DataTreeModification} implementation which delegates all calls to
public synchronized void applyToCursor(@Nonnull final DataTreeModificationCursor cursor) {
delegate.applyToCursor(cursor);
}
+
+ @Override
+ public synchronized SchemaContext getSchemaContext() {
+ return delegate.getSchemaContext();
+ }
}
import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return strategyTree;
}
+ @Override
+ public SchemaContext getSchemaContext() {
+ return snapshot.getSchemaContext();
+ }
+
@Override
public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkSealed();
import java.util.Optional;
import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
final class InMemoryDataTreeSnapshot extends AbstractCursorAware implements CursorAwareDataTreeSnapshot {
- private final RootModificationApplyOperation applyOper;
- private final SchemaContext schemaContext;
- private final TreeNode rootNode;
+ private final @NonNull RootModificationApplyOperation applyOper;
+ private final @NonNull SchemaContext schemaContext;
+ private final @NonNull TreeNode rootNode;
InMemoryDataTreeSnapshot(final SchemaContext schemaContext, final TreeNode rootNode,
final RootModificationApplyOperation applyOper) {
return rootNode;
}
- SchemaContext getSchemaContext() {
+ @Override
+ public SchemaContext getSchemaContext() {
return schemaContext;
}