2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.api.schema.tree;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
12 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
15 * Factory interface for creating data trees.
17 public interface DataTreeFactory {
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.
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
31 * @return A data tree instance.
32 * @throws NullPointerException if treeConfig is null
34 @NonNull DataTree create(DataTreeConfiguration treeConfig);
37 * Create a new data tree based on specified configuration, with a root node derived from the schema context lookup
38 * of the configuration. Mandatory nodes whose enforcement point is the root node will not be enforced even if some
39 * are present in the SchemaContext and validation is requested in configuration.
43 * @return A data tree instance.
44 * @throws NullPointerException if any of the arguments are null
45 * @throws IllegalArgumentException if tree configuration does not match the SchemaContext, for example by root path
46 * referring to a node which does not exist in the SchemaContext
48 @NonNull DataTree create(DataTreeConfiguration treeConfig, EffectiveModelContext initialSchemaContext);
51 * Create a new data tree based on specified configuration, with the specified node.
55 * @return A data tree instance.
56 * @throws DataValidationFailedException if initial root is not valid according to the schema context
57 * @throws NullPointerException if any of the arguments are null
58 * @throws IllegalArgumentException if a mismatch between the arguments is detected
60 @NonNull DataTree create(DataTreeConfiguration treeConfig, EffectiveModelContext initialSchemaContext,
61 NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException;