import static com.google.common.base.Preconditions.checkArgument;
import java.util.Optional;
+import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNull;
import org.kohsuke.MetaInfServices;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
+import org.opendaylight.yangtools.yang.model.api.ContainerLike;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.osgi.service.component.annotations.Activate;
private static final @NonNull NormalizedNode<?, ?> ROOT_CONTAINER =
ImmutableNodes.containerNode(SchemaContext.NAME);
+ @Inject
+ public InMemoryDataTreeFactory() {
+ // Exposed for DI
+ }
+
@Override
public DataTree create(final DataTreeConfiguration treeConfig) {
return new InMemoryDataTree(TreeNodeFactory.createTreeNode(createRoot(treeConfig.getRootPath()),
}
@Override
- public DataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext) {
+ public DataTree create(final DataTreeConfiguration treeConfig, final EffectiveModelContext initialSchemaContext) {
return createDataTree(treeConfig, initialSchemaContext, true);
}
@Override
- public DataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext,
+ public DataTree create(final DataTreeConfiguration treeConfig, final EffectiveModelContext initialSchemaContext,
final NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException {
final DataTree ret = createDataTree(treeConfig, initialSchemaContext, false);
}
private static @NonNull DataTree createDataTree(final DataTreeConfiguration treeConfig,
- final SchemaContext initialSchemaContext, final boolean maskMandatory) {
+ final EffectiveModelContext initialSchemaContext, final boolean maskMandatory) {
final DataSchemaNode rootSchemaNode = getRootSchemaNode(initialSchemaContext, treeConfig.getRootPath());
final NormalizedNode<?, ?> rootDataNode = createRoot((DataNodeContainer)rootSchemaNode,
treeConfig.getRootPath());
private static @NonNull NormalizedNode<?, ?> createRoot(final DataNodeContainer schemaNode,
final YangInstanceIdentifier path) {
if (path.isEmpty()) {
- checkArgument(schemaNode instanceof ContainerSchemaNode,
+ checkArgument(schemaNode instanceof ContainerLike,
"Conceptual tree root has to be a container, not %s", schemaNode);
return ROOT_CONTAINER;
}
throw new IllegalArgumentException("Unsupported root node " + arg);
}
- private static DataSchemaNode getRootSchemaNode(final SchemaContext schemaContext,
+ private static DataSchemaNode getRootSchemaNode(final EffectiveModelContext schemaContext,
final YangInstanceIdentifier rootPath) {
final DataSchemaContextTree contextTree = DataSchemaContextTree.from(schemaContext);
final Optional<DataSchemaContextNode<?>> rootContextNode = contextTree.findChild(rootPath);