X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2Fcommands%2Finput%2FInput.java;fp=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2Fcommands%2Finput%2FInput.java;h=02173acf7736133bddb2fb71c2e446a028c29cb2;hp=0000000000000000000000000000000000000000;hb=b3d2a00776a1a5e3a139d73ced859aa557c931af;hpb=d04e0863b86415749a8437241c57df0d32a3b133 diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/commands/input/Input.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/commands/input/Input.java new file mode 100644 index 0000000000..02173acf77 --- /dev/null +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/commands/input/Input.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.netconf.cli.commands.input; + +import com.google.common.base.Preconditions; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; + +/** + * Input arguments for and rpc/command execution + */ +public class Input { + + private final List> args; + + private final Map> nameToArg = new HashMap>(); + + public Input(final List> args) { + // FIXME empty Input should be constructed from static factory method + if(args.isEmpty()) { + this.args = Collections.emptyList(); + return; + } + + final Node input = args.iterator().next(); + Preconditions + .checkArgument(input instanceof CompositeNode, "Input container has to be of type composite node."); + this.args = ((CompositeNode) input).getValue(); + + for (final Node arg : this.args) { + nameToArg.put(arg.getNodeType().getLocalName(), arg); + } + } + + public Node getArg(final String name) { + return nameToArg.get(name); + } + + public CompositeNode wrap(final QName rpcQName) { + return new CompositeNodeTOImpl(rpcQName, null, args); + } +}