BUG 2970 : Create a PruningDataTreeModification
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeSnapshot.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 class ShardDataTreeSnapshot implements DataTreeSnapshot {
21
22     private final DataTreeSnapshot dataTreeSnapshot;
23     private final Set<URI> validNamespaces;
24
25     public ShardDataTreeSnapshot(DataTreeSnapshot dataTreeSnapshot, Set<URI> validNamespaces) {
26         this.dataTreeSnapshot = dataTreeSnapshot;
27         this.validNamespaces = validNamespaces;
28     }
29
30     @Override
31     public Optional<NormalizedNode<?, ?>> readNode(YangInstanceIdentifier yangInstanceIdentifier) {
32         return this.dataTreeSnapshot.readNode(yangInstanceIdentifier);
33     }
34
35     @Override
36     public DataTreeModification newModification() {
37         return new PruningDataTreeModification(this.dataTreeSnapshot.newModification(), validNamespaces);
38     }
39
40
41 }