Bug 2970: Remove SchemaContextModules perisistence
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / PruningShardDataTreeSnapshot.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.controller.cluster.datastore;
10
11 import com.google.common.base.Optional;
12 import java.net.URI;
13 import java.util.Set;
14 import org.opendaylight.controller.cluster.datastore.utils.PruningDataTreeModification;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
18 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
19
20 /**
21  * The PruningShardDataTreeSnapshot returns a PruningDataTreeModification when a newModification is created
22  */
23 class PruningShardDataTreeSnapshot implements DataTreeSnapshot {
24
25     private final DataTreeSnapshot dataTreeSnapshot;
26     private final Set<URI> validNamespaces;
27
28     public PruningShardDataTreeSnapshot(DataTreeSnapshot dataTreeSnapshot, Set<URI> validNamespaces) {
29         this.dataTreeSnapshot = dataTreeSnapshot;
30         this.validNamespaces = validNamespaces;
31     }
32
33     @Override
34     public Optional<NormalizedNode<?, ?>> readNode(YangInstanceIdentifier yangInstanceIdentifier) {
35         return this.dataTreeSnapshot.readNode(yangInstanceIdentifier);
36     }
37
38     @Override
39     public DataTreeModification newModification() {
40         return new PruningDataTreeModification(this.dataTreeSnapshot.newModification(), validNamespaces);
41     }
42
43
44 }