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.impl.schema.tree;
10 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
11 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
12 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
15 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 * A factory for creating in-memory data trees.
21 public final class InMemoryDataTreeFactory implements DataTreeFactory {
22 private static final InMemoryDataTreeFactory INSTANCE = new InMemoryDataTreeFactory();
24 private InMemoryDataTreeFactory() {
25 // Never instantiated externally
29 public InMemoryDataTree create() {
30 final NodeIdentifier root = new NodeIdentifier(SchemaContext.NAME);
31 final NormalizedNode<?, ?> data = Builders.containerBuilder().withNodeIdentifier(root).build();
33 return new InMemoryDataTree(TreeNodeFactory.createTreeNode(data, Version.initial()), null);
37 * Get an instance of this factory. This method cannot fail.
39 * @return Data tree factory instance.
41 public static final InMemoryDataTreeFactory getInstance() {