Update DataTreeFactory 37/65037/5
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Nov 2017 09:43:01 +0000 (10:43 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 3 Nov 2017 15:46:02 +0000 (16:46 +0100)
This patch removes deprecated methods, adds a correctness note to
the single-argument create() method and promotes the other two to
non-Beta status.

Change-Id: I2a081dfa1dadcd19aa7b70109b6cca2be88c10be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeFactory.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeFactory.java

index ef0958f2fbc4009be3e20a5ab471c382a238a479..f7becfe3f88c98bca6cddd2d30e3a3827cba1fd2 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema.tree;
 
  */
 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;
 
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
@@ -16,35 +14,17 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  * Factory interface for creating data trees.
  */
 public interface DataTreeFactory {
  * Factory interface for creating data trees.
  */
 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 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.
      *
     /**
      * 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.
      *
+     * <p>
+     * Correctness note: this method may not accurately initialize the root node in certain non-root scenarios due to
+     * the impossibility to accurately derive root type from plain YangInstanceIdentifier. Using
+     * {@link #create(DataTreeConfiguration, SchemaContext)} is recommended, as it does not suffer from this
+     * shortcoming.
+     *
      * @param treeConfig
      *          Tree configuration.
      * @return A data tree instance.
      * @param treeConfig
      *          Tree configuration.
      * @return A data tree instance.
@@ -64,7 +44,6 @@ public interface DataTreeFactory {
      * @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
      */
      * @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);
 
     /**
     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
 
     /**
@@ -77,7 +56,6 @@ public interface DataTreeFactory {
      * @throws NullPointerException if any of the arguments are null
      * @throws IllegalArgumentException if a mismatch between the arguments is detected
      */
      * @throws NullPointerException if any of the arguments are null
      * @throws IllegalArgumentException if a mismatch between the arguments is detected
      */
-    @Beta
     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
             NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
 }
     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
             NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
 }
index a44ae5c98c2e22697266bc02b2af378fd3171a21..ab89a5cccf39e84937a9fa76da2abe332e660889 100644 (file)
@@ -17,12 +17,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration.Builder;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
@@ -46,32 +44,6 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
         // Never instantiated externally
     }
 
         // Never instantiated externally
     }
 
-    @Deprecated
-    @Override
-    public TipProducingDataTree create(final TreeType treeType) {
-        return create(DataTreeConfiguration.getDefault(treeType));
-    }
-
-    @Deprecated
-    @Override
-    public TipProducingDataTree create(final TreeType treeType, final YangInstanceIdentifier rootPath) {
-        if (rootPath.isEmpty()) {
-            return create(treeType);
-        }
-
-        final DataTreeConfiguration defConfig = DataTreeConfiguration.getDefault(treeType);
-        final DataTreeConfiguration config;
-        if (!rootPath.isEmpty()) {
-            config = new Builder(treeType).setMandatoryNodesValidation(defConfig.isMandatoryNodesValidationEnabled())
-                    .setRootPath(rootPath).setUniqueIndexes(defConfig.isUniqueIndexEnabled()).build();
-        } else {
-            config = defConfig;
-        }
-
-        return new InMemoryDataTree(TreeNodeFactory.createTreeNode(createRoot(rootPath), Version.initial()), config,
-            null);
-    }
-
     @Override
     public TipProducingDataTree create(final DataTreeConfiguration treeConfig) {
         return new InMemoryDataTree(TreeNodeFactory.createTreeNode(createRoot(treeConfig.getRootPath()),
     @Override
     public TipProducingDataTree create(final DataTreeConfiguration treeConfig) {
         return new InMemoryDataTree(TreeNodeFactory.createTreeNode(createRoot(treeConfig.getRootPath()),