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.tree.impl;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
17 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
19 final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
20 private static final class RootNode extends AbstractModifiedNodeBasedCandidateNode {
21 RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
22 super(mod, oldMeta, newMeta);
26 public PathArgument name() {
27 throw new IllegalStateException("Attempted to get identifier of the root node");
31 private final @NonNull RootNode root;
33 InMemoryDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
34 final TreeNode beforeRoot, final TreeNode afterRoot) {
36 root = new RootNode(modificationRoot, requireNonNull(beforeRoot), requireNonNull(afterRoot));
40 protected TreeNode getTipRoot() {
41 return root.getNewMeta();
44 TreeNode getBeforeRoot() {
45 return root.getOldMeta();
49 public DataTreeCandidateNode getRootNode() {
54 public String toString() {
55 return MoreObjects.toStringHelper(this).add("rootPath", getRootPath()).add("rootNode", getRootNode())