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
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.api.schema.tree;
9
10 import com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14
15 /**
16  * Factory interface for creating data trees.
17  */
18 public interface DataTreeFactory {
19     /**
20      * Create a new data tree.
21      * @param type
22      *          Tree type.
23      * @return A data tree instance.
24      *
25      * @deprecated Use {@link #create(DataTreeConfiguration)} instead.
26      */
27     @Deprecated
28     DataTree create(TreeType type);
29
30     /**
31      * Create a new data tree rooted at a particular node.
32      * @param treeType
33      *          Tree type.
34      * @param rootPath
35      *          Root.
36      * @return A data tree instance.
37      *
38     * @deprecated Use {@link #create(DataTreeConfiguration)} instead.
39      */
40     @Deprecated
41     DataTree create(TreeType treeType, YangInstanceIdentifier rootPath);
42
43     /**
44      * Create a new data tree based on specified configuration, with a best-guess root. Use this method only if you
45      * do not have a corresponding SchemaContext handy. Mandatory nodes whose enforcement point is the root node will
46      * not be enforced even if some are present in the SchemaContext and validation is requested in configuration.
47      *
48      * @param treeConfig
49      *          Tree configuration.
50      * @return A data tree instance.
51      * @throws NullPointerException if treeConfig is null
52      */
53     DataTree create(DataTreeConfiguration treeConfig);
54
55     /**
56      * Create a new data tree based on specified configuration, with a root node derived from the schema context lookup
57      * of the configuration. Mandatory nodes whose enforcement point is the root node will not be enforced even if some
58      * are present in the SchemaContext and validation is requested in configuration.
59      *
60      * @param treeConfig
61      *          Tree configuration.
62      * @return A data tree instance.
63      * @throws NullPointerException if any of the arguments are null
64      * @throws IllegalArgumentException if tree configuration does not match the SchemaContext, for example by root path
65      *                                  referring to a node which does not exist in the SchemaContext
66      */
67     @Beta
68     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
69
70     /**
71      * Create a new data tree based on specified configuration, with the specified node.
72      *
73      * @param treeConfig
74      *          Tree configuration.
75      * @return A data tree instance.
76      * @throws DataValidationFailedException if initial root is not valid according to the schema context
77      * @throws NullPointerException if any of the arguments are null
78      * @throws IllegalArgumentException if a mismatch between the arguments is detected
79      */
80     @Beta
81     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
82             NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
83 }