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 static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import java.util.Collection;
14 import java.util.Collections;
15 import java.util.Optional;
16 import javax.annotation.Nonnull;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
21 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
22 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
25 * Internal utility class for an empty candidate. We instantiate this class
26 * for empty modifications, saving memory and processing speed. Instances
27 * of this class are explicitly recognized and processing of them is skipped.
29 final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
30 private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() {
33 public ModificationType getModificationType() {
34 return ModificationType.UNMODIFIED;
39 public Collection<DataTreeCandidateNode> getChildNodes() {
40 return Collections.emptyList();
45 public PathArgument getIdentifier() {
46 throw new IllegalStateException("Attempted to read identifier of the no-operation change");
51 public Optional<NormalizedNode<?, ?>> getDataAfter() {
52 return Optional.empty();
57 public Optional<NormalizedNode<?, ?>> getDataBefore() {
58 return Optional.empty();
62 public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
66 private final TreeNode afterRoot;
68 protected NoopDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
69 final TreeNode afterRoot) {
71 checkArgument(modificationRoot.getOperation() == LogicalOperation.NONE);
72 this.afterRoot = requireNonNull(afterRoot);
76 public DataTreeCandidateNode getRootNode() {
82 protected TreeNode getTipRoot() {