Merge "Distributed Datastore integration with config subsystem Updated with the usage...
[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 java.util.Set;
14 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16
17 /**
18  * The definition of output elements represented by schema nodes parsed from yang rpc definition
19  */
20 public class OutputDefinition implements Iterable<DataSchemaNode> {
21
22     public static final OutputDefinition EMPTY_OUTPUT = new OutputDefinition(Collections.<DataSchemaNode>emptySet());
23     private final Set<DataSchemaNode> childNodes;
24
25     public OutputDefinition(final Set<DataSchemaNode> childNodes) {
26         this.childNodes = childNodes;
27     }
28
29     @Override
30     public Iterator<DataSchemaNode> iterator() {
31         return childNodes.iterator();
32     }
33
34     public static OutputDefinition fromOutput(final ContainerSchemaNode output) {
35         Preconditions.checkNotNull(output);
36         return new OutputDefinition(output.getChildNodes());
37     }
38
39     public static OutputDefinition empty() {
40         return EMPTY_OUTPUT;
41     }
42
43     public boolean isEmpty() {
44         return this == EMPTY_OUTPUT;
45     }
46
47 }