BUG-8291: expose additional DataTreeFactory methods
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / DataTreeFactory.java
index e82982d4f354cc5ff9ea178b190cd35e50d39187..ef0958f2fbc4009be3e20a5ab471c382a238a479 100644 (file)
@@ -7,7 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
+import com.google.common.annotations.Beta;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * Factory interface for creating data trees.
@@ -17,28 +20,64 @@ public interface DataTreeFactory {
      * Create a new data tree.
      * @param type
      *          Tree type.
-     *
      * @return A data tree instance.
+     *
+     * @deprecated Use {@link #create(DataTreeConfiguration)} instead.
      */
+    @Deprecated
     DataTree create(TreeType type);
 
     /**
-     * Create a new data tree.
-     * @param treeConfig
-     *          Tree config.
+     * Create a new data tree rooted at a particular node.
+     * @param treeType
+     *          Tree type.
+     * @param rootPath
+     *          Root.
+     * @return A data tree instance.
+     *
+    * @deprecated Use {@link #create(DataTreeConfiguration)} instead.
+     */
+    @Deprecated
+    DataTree create(TreeType treeType, YangInstanceIdentifier rootPath);
+
+    /**
+     * Create a new data tree based on specified configuration, with a best-guess root. Use this method only if you
+     * do not have a corresponding SchemaContext handy. Mandatory nodes whose enforcement point is the root node will
+     * not be enforced even if some are present in the SchemaContext and validation is requested in configuration.
      *
+     * @param treeConfig
+     *          Tree configuration.
      * @return A data tree instance.
+     * @throws NullPointerException if treeConfig is null
      */
     DataTree create(DataTreeConfiguration treeConfig);
 
     /**
-     * Create a new data tree rooted at a particular node.
-     * @param treeType
-     *          Tree type.
-     * @param rootPath
-     *          Root.
+     * Create a new data tree based on specified configuration, with a root node derived from the schema context lookup
+     * of the configuration. Mandatory nodes whose enforcement point is the root node will not be enforced even if some
+     * are present in the SchemaContext and validation is requested in configuration.
+     *
+     * @param treeConfig
+     *          Tree configuration.
+     * @return A data tree instance.
+     * @throws NullPointerException if any of the arguments are null
+     * @throws IllegalArgumentException if tree configuration does not match the SchemaContext, for example by root path
+     *                                  referring to a node which does not exist in the SchemaContext
+     */
+    @Beta
+    DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
+
+    /**
+     * Create a new data tree based on specified configuration, with the specified node.
      *
+     * @param treeConfig
+     *          Tree configuration.
      * @return A data tree instance.
+     * @throws DataValidationFailedException if initial root is not valid according to the schema context
+     * @throws NullPointerException if any of the arguments are null
+     * @throws IllegalArgumentException if a mismatch between the arguments is detected
      */
-    DataTree create(TreeType treeType, YangInstanceIdentifier rootPath);
+    @Beta
+    DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
+            NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
 }