CDS: Add stress test RPC to the cars model
[controller.git] / opendaylight / netconf / netconf-cli / src / main / java / org / opendaylight / controller / netconf / cli / writer / impl / AugmentationNodeCliSerializer.java
1 /*
2  * Copyright (c) 2013 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.netconf.cli.writer.impl;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import org.opendaylight.controller.netconf.cli.writer.OutFormatter;
13 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
14 import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.AugmentationNodeBaseSerializer;
15 import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
17 final class AugmentationNodeCliSerializer extends AugmentationNodeBaseSerializer<String> {
18
19     private final NodeSerializerDispatcher<String> dispatcher;
20     private final OutFormatter out;
21
22     AugmentationNodeCliSerializer(final OutFormatter out, final NodeSerializerDispatcher<String> dispatcher) {
23         this.out = Preconditions.checkNotNull(out);
24         this.dispatcher = Preconditions.checkNotNull(dispatcher);
25     }
26
27     @Override
28     public Iterable<String> serialize(final AugmentationSchema schema, final AugmentationNode node) {
29         final StringBuilder output = new StringBuilder();
30         out.increaseIndent();
31         out.addStringWithIndent(output, "augment");
32         out.openComposite(output);
33         out.newLine(output);
34
35         for (final String childOutput : super.serialize(schema, node)) {
36             output.append(childOutput);
37             out.newLine(output);
38         }
39
40         out.closeCompositeWithIndent(output);
41         out.decreaseIndent();
42         return Collections.singletonList(output.toString());
43     }
44
45     @Override
46     protected NodeSerializerDispatcher<String> getNodeDispatcher() {
47         return dispatcher;
48     }
49 }