2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.netconf.cli.commands.input;
10 import com.google.common.base.Preconditions;
11 import java.util.Collections;
12 import java.util.HashMap;
13 import java.util.List;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
17 import org.opendaylight.yangtools.yang.data.api.Node;
18 import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl;
21 * Input arguments for and rpc/command execution
25 private final List<Node<?>> args;
27 private final Map<String, Node<?>> nameToArg = new HashMap<String, Node<?>>();
29 public Input(final List<Node<?>> args) {
30 // FIXME empty Input should be constructed from static factory method
32 this.args = Collections.emptyList();
36 final Node<?> input = args.iterator().next();
38 .checkArgument(input instanceof CompositeNode, "Input container has to be of type composite node.");
39 this.args = ((CompositeNode) input).getValue();
41 for (final Node<?> arg : this.args) {
42 nameToArg.put(arg.getNodeType().getLocalName(), arg);
46 public Node<?> getArg(final String name) {
47 return nameToArg.get(name);
50 public CompositeNode wrap(final QName rpcQName) {
51 return new CompositeNodeTOImpl(rpcQName, null, args);