66d0d4da4673e16650bea4e6a46b864847b160e6
[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 }

©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.