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.controller.md.sal.dom.store.impl.tree.data;
10 import java.util.Collections;
12 import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode;
13 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 import com.google.common.base.Optional;
19 import com.google.common.base.Preconditions;
22 * Internal utility class for an empty candidate. We instantiate this class
23 * for empty modifications, saving memory and processing speed. Instances
24 * of this class are explicitly recognized and processing of them is skipped.
26 final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
27 private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() {
29 public ModificationType getModificationType() {
30 return ModificationType.UNMODIFIED;
34 public Iterable<DataTreeCandidateNode> getChildNodes() {
35 return Collections.emptyList();
39 public PathArgument getIdentifier() {
40 throw new IllegalStateException("Attempted to read identifier of the no-operation change");
44 public Optional<NormalizedNode<?, ?>> getDataAfter() {
45 return Optional.absent();
49 public Optional<NormalizedNode<?, ?>> getDataBefore() {
50 return Optional.absent();
54 protected NoopDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot) {
56 Preconditions.checkArgument(modificationRoot.getType() == ModificationType.UNMODIFIED);
60 public DataTreeCandidateNode getRootNode() {