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 com.google.common.base.MoreObjects;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
13 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
14 import org.opendaylight.yangtools.yang.data.spi.tree.TreeNode;
16 final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
18 private static final class RootNode extends AbstractModifiedNodeBasedCandidateNode {
19 RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
20 super(mod, oldMeta, newMeta);
24 public PathArgument getIdentifier() {
25 throw new IllegalStateException("Attempted to get identifier of the root node");
29 private final RootNode root;
31 InMemoryDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
32 final TreeNode beforeRoot, final TreeNode afterRoot) {
34 this.root = new RootNode(modificationRoot, beforeRoot, afterRoot);
38 protected TreeNode getTipRoot() {
39 return root.getNewMeta();
42 TreeNode getBeforeRoot() {
43 return root.getOldMeta();
47 public DataTreeCandidateNode getRootNode() {
52 public String toString() {
53 return MoreObjects.toStringHelper(this).add("rootPath", getRootPath())
54 .add("rootNode", getRootNode()).toString();