CDS: Add stress test RPC to the cars model
[controller.git] / opendaylight / netconf / netconf-cli / src / main / java / org / opendaylight / controller / netconf / cli / commands / output / OutputDefinition.java
1 /*
2  * Copyright (c) 2014 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.commands.output;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import java.util.Iterator;
13 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
15
16 /**
17  * The definition of output elements represented by schema nodes parsed from yang rpc definition
18  */
19 public class OutputDefinition implements Iterable<DataSchemaNode> {
20
21     public static final OutputDefinition EMPTY_OUTPUT = new OutputDefinition(Collections.<DataSchemaNode>emptySet());
22     private final Iterable<DataSchemaNode> childNodes;
23
24     public OutputDefinition(final Iterable<DataSchemaNode> childNodes) {
25         this.childNodes = childNodes;
26     }
27
28     @Override
29     public Iterator<DataSchemaNode> iterator() {
30         return childNodes.iterator();
31     }
32
33     public static OutputDefinition fromOutput(final ContainerSchemaNode output) {
34         Preconditions.checkNotNull(output);
35         return new OutputDefinition(output.getChildNodes());
36     }
37
38     public static OutputDefinition empty() {
39         return EMPTY_OUTPUT;
40     }
41
42     public boolean isEmpty() {
43         return this == EMPTY_OUTPUT;
44     }
45
46 }