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 javax.annotation.Nonnull;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
17 final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
19 private static final class RootNode extends AbstractModifiedNodeBasedCandidateNode {
20 RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
21 super(mod, oldMeta, newMeta);
26 public PathArgument getIdentifier() {
27 throw new IllegalStateException("Attempted to get identifier of the root node");
31 private final RootNode root;
33 InMemoryDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
34 final TreeNode beforeRoot, final TreeNode afterRoot) {
36 this.root = new RootNode(modificationRoot, beforeRoot, afterRoot);
41 protected TreeNode getTipRoot() {
42 return root.getNewMeta();
45 TreeNode getBeforeRoot() {
46 return root.getOldMeta();
50 public DataTreeCandidateNode getRootNode() {
55 public String toString() {
56 return MoreObjects.toStringHelper(this).add("rootPath", getRootPath())
57 .add("rootNode", getRootNode()).toString();