9367118bf45878b3699cc934362c2d94d730b814
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / NormalizedNodePrinter.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 org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
12 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14
15 public class NormalizedNodePrinter implements NormalizedNodeVisitor {
16
17     private String spaces(int n){
18         StringBuilder builder = new StringBuilder();
19         for(int i=0;i<n;i++){
20             builder.append(' ');
21         }
22         return builder.toString();
23     }
24
25     @Override
26     public void visitNode(int level, String parentPath, NormalizedNode<?, ?> normalizedNode) {
27         System.out.println(spaces((level) * 4) + normalizedNode.getClass().toString() + ":" + normalizedNode.getIdentifier());
28         if(normalizedNode instanceof LeafNode || normalizedNode instanceof LeafSetEntryNode){
29             System.out.println(spaces((level) * 4) + " parentPath = " + parentPath);
30             System.out.println(spaces((level) * 4) + " key = " + normalizedNode.getClass().toString() + ":" + normalizedNode.getIdentifier());
31             System.out.println(spaces((level) * 4) + " value = " + normalizedNode.getValue());
32         }
33     }
34 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.