Remove NormalizedNodeStreamReader
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / NormalizedNodeGetter.java
1 /*
2  * Copyright (c) 2014, 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.node.utils;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13
14 public class NormalizedNodeGetter implements
15     NormalizedNodeVisitor {
16     private final String path;
17     NormalizedNode<?, ?> output;
18
19     public NormalizedNodeGetter(String path){
20         Preconditions.checkNotNull(path);
21         this.path = path;
22     }
23
24     @Override
25     public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
26         String nodePath = parentPath + "/"+ PathUtils.toString(normalizedNode.getIdentifier());
27
28         if(nodePath.toString().equals(path)){
29             output = normalizedNode;
30         }
31     }
32
33     public NormalizedNode<?, ?> getOutput(){
34         return output;
35     }
36 }