Split out ReadOnlyDataTree interface 76/81176/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Mar 2019 11:50:42 +0000 (12:50 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 26 Mar 2019 12:11:33 +0000 (13:11 +0100)
Having a read-only view of the DataTree operations allows us to
more safely express access rules, i.e. make it impossible for illegal
access to occur.

Change-Id: I67ae6c8423f63f0686cc7ba2286b0df4b44585ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTree.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/ReadOnlyDataTree.java [new file with mode: 0644]

index 2c61b5f95f4573070f1b959b43124df4eb39935f..9c9b26d5fb7d19a7f38cdc05b7bf96e24b1de919 100644 (file)
@@ -7,21 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * 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.
-     *
-     * @return Data tree snapshot.
-     */
-    DataTreeSnapshot takeSnapshot();
-
+public interface DataTree extends DataTreeTip, ReadOnlyDataTree {
     /**
      * Make the data tree use a new schema context. The context will be used
      * only by subsequent operations.
@@ -37,11 +28,4 @@ public interface DataTree extends DataTreeTip {
      * @param candidate data tree candidate
      */
     void commit(DataTreeCandidate candidate);
-
-    /**
-     * Get the root path of this data tree.
-     *
-     * @return The tree's root path.
-     */
-    YangInstanceIdentifier getRootPath();
 }
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/ReadOnlyDataTree.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/ReadOnlyDataTree.java
new file mode 100644 (file)
index 0000000..afe560b
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.api.schema.tree;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+/**
+ * A read-only view of a {@link DataTree}. This provides access to MVCC access methods, but unlike {@link DataTree},
+ * it does not expose methods to affect internal state.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@NonNullByDefault
+public interface ReadOnlyDataTree {
+    /**
+     * Get the root path of this data tree.
+     *
+     * @return The tree's root path.
+     */
+    YangInstanceIdentifier getRootPath();
+
+    /**
+     * Take a read-only point-in-time snapshot of the tree.
+     *
+     * @return Data tree snapshot.
+     */
+    DataTreeSnapshot takeSnapshot();
+}