Merge "Neutron API v2.0 bindings and APIs for security groups/rules."
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / tree / data / NoopDataTreeCandidate.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.dom.store.impl.tree.data;
9
10 import java.util.Collections;
11
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;
17
18 import com.google.common.base.Optional;
19 import com.google.common.base.Preconditions;
20
21 final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
22     private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() {
23         @Override
24         public ModificationType getModificationType() {
25             return ModificationType.UNMODIFIED;
26         }
27
28         @Override
29         public Iterable<DataTreeCandidateNode> getChildNodes() {
30             return Collections.emptyList();
31         }
32
33         @Override
34         public PathArgument getIdentifier() {
35             throw new IllegalStateException("Attempted to read identifier of the no-operation change");
36         }
37
38         @Override
39         public Optional<NormalizedNode<?, ?>> getDataAfter() {
40             return Optional.absent();
41         }
42
43         @Override
44         public Optional<NormalizedNode<?, ?>> getDataBefore() {
45             return Optional.absent();
46         }
47     };
48
49     protected NoopDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot) {
50         super(rootPath);
51         Preconditions.checkArgument(modificationRoot.getType() == ModificationType.UNMODIFIED);
52     }
53
54     @Override
55     public DataTreeCandidateNode getRootNode() {
56         return ROOT;
57     }
58 }