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