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 com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import java.util.Collection;
14 import java.util.List;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
20 import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
21 import org.opendaylight.yangtools.yang.data.tree.impl.node.TreeNode;
24 * Internal utility class for an empty candidate. We instantiate this class
25 * for empty modifications, saving memory and processing speed. Instances
26 * of this class are explicitly recognized and processing of them is skipped.
28 final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
29 private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() {
31 public ModificationType modificationType() {
32 return ModificationType.UNMODIFIED;
36 public Collection<DataTreeCandidateNode> childNodes() {
41 public PathArgument name() {
42 throw new IllegalStateException("Attempted to read identifier of the no-operation change");
46 public NormalizedNode dataAfter() {
51 public NormalizedNode dataBefore() {
56 public DataTreeCandidateNode modifiedChild(final PathArgument identifier) {
61 private final @NonNull TreeNode afterRoot;
63 protected NoopDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
64 final TreeNode afterRoot) {
66 checkArgument(modificationRoot.getOperation() == LogicalOperation.NONE);
67 this.afterRoot = requireNonNull(afterRoot);
71 public DataTreeCandidateNode getRootNode() {
76 protected TreeNode getTipRoot() {