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.schema.NormalizedNode;
11 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
12 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
16 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 * A factory for creating in-memory data trees.
22 public final class InMemoryDataTreeFactory implements DataTreeFactory {
23 private static final InMemoryDataTreeFactory INSTANCE = new InMemoryDataTreeFactory();
24 private final NormalizedNode<?, ?> root = ImmutableNodes.containerNode(SchemaContext.NAME);
26 private InMemoryDataTreeFactory() {
27 // Never instantiated externally
31 public TipProducingDataTree create() {
32 return create(TreeType.OPERATIONAL);
36 public TipProducingDataTree create(TreeType treeType) {
37 return new InMemoryDataTree(TreeNodeFactory.createTreeNode(root, Version.initial()), treeType, null);
41 * Get an instance of this factory. This method cannot fail.
43 * @return Data tree factory instance.
45 public static InMemoryDataTreeFactory getInstance() {