Merge branch 'master' of ../controller
[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 org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
11 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
12
13 /**
14  * Factory interface for creating data trees.
15  */
16 public interface DataTreeFactory {
17     /**
18      * Create a new data tree based on specified configuration, with a best-guess root. Use this method only if you
19      * do not have a corresponding SchemaContext handy. Mandatory nodes whose enforcement point is the root node will
20      * not be enforced even if some are present in the SchemaContext and validation is requested in configuration.
21      *
22      * <p>
23      * Correctness note: this method may not accurately initialize the root node in certain non-root scenarios due to
24      * the impossibility to accurately derive root type from plain YangInstanceIdentifier. Using
25      * {@link #create(DataTreeConfiguration, SchemaContext)} is recommended, as it does not suffer from this
26      * shortcoming.
27      *
28      * @param treeConfig
29      *          Tree configuration.
30      * @return A data tree instance.
31      * @throws NullPointerException if treeConfig is null
32      */
33     DataTree create(DataTreeConfiguration treeConfig);
34
35     /**
36      * Create a new data tree based on specified configuration, with a root node derived from the schema context lookup
37      * of the configuration. Mandatory nodes whose enforcement point is the root node will not be enforced even if some
38      * are present in the SchemaContext and validation is requested in configuration.
39      *
40      * @param treeConfig
41      *          Tree configuration.
42      * @return A data tree instance.
43      * @throws NullPointerException if any of the arguments are null
44      * @throws IllegalArgumentException if tree configuration does not match the SchemaContext, for example by root path
45      *                                  referring to a node which does not exist in the SchemaContext
46      */
47     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext);
48
49     /**
50      * Create a new data tree based on specified configuration, with the specified node.
51      *
52      * @param treeConfig
53      *          Tree configuration.
54      * @return A data tree instance.
55      * @throws DataValidationFailedException if initial root is not valid according to the schema context
56      * @throws NullPointerException if any of the arguments are null
57      * @throws IllegalArgumentException if a mismatch between the arguments is detected
58      */
59     DataTree create(DataTreeConfiguration treeConfig, SchemaContext initialSchemaContext,
60             NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;
61 }