X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2Freader%2Fcustom%2FEditContentReader.java;fp=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2Freader%2Fcustom%2FEditContentReader.java;h=af43d379092eb3337aa5deaa75f568f4f7522039;hb=b3d2a00776a1a5e3a139d73ced859aa557c931af;hp=0000000000000000000000000000000000000000;hpb=d04e0863b86415749a8437241c57df0d32a3b133;p=controller.git diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/custom/EditContentReader.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/custom/EditContentReader.java new file mode 100644 index 0000000000..af43d37909 --- /dev/null +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/custom/EditContentReader.java @@ -0,0 +1,43 @@ +/* + * 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.reader.custom; + +import com.google.common.base.Preconditions; +import java.io.IOException; +import java.util.List; +import org.opendaylight.controller.netconf.cli.CommandArgHandlerRegistry; +import org.opendaylight.controller.netconf.cli.commands.CommandConstants; +import org.opendaylight.controller.netconf.cli.io.ConsoleIO; +import org.opendaylight.controller.netconf.cli.reader.ReadingException; +import org.opendaylight.controller.netconf.cli.reader.impl.ChoiceReader; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.ChoiceNode; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +public class EditContentReader extends ChoiceReader { + + public static final QName EDIT_CONTENT_QNAME = QName.create(CommandConstants.NETCONF_BASE_QNAME, "edit-content"); + public static final QName CONFIG_QNAME = QName.create(EDIT_CONTENT_QNAME, "config"); + + // FIXME this could be removed if feature/if-feature are supported + + public EditContentReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry, final SchemaContext schemaContext) { + super(console, argumentHandlerRegistry, schemaContext); + } + + @Override + public List> readWithContext(final ChoiceNode choiceNode) throws IOException, ReadingException { + Preconditions.checkState(choiceNode.getQName().equals(EDIT_CONTENT_QNAME), "Unexpected choice %s, expected %s", choiceNode, EDIT_CONTENT_QNAME); + final ChoiceCaseNode selectedCase = choiceNode.getCaseNodeByName(CONFIG_QNAME); + Preconditions.checkNotNull(selectedCase, "Unexpected choice %s, expected %s that contains %s", choiceNode, EDIT_CONTENT_QNAME, CONFIG_QNAME); + return readSelectedCase(selectedCase); + } + +}