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%2Freader%2Fimpl%2FChoiceReader.java;fp=opendaylight%2Fnetconf%2Fnetconf-cli%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fcli%2Freader%2Fimpl%2FChoiceReader.java;h=74223193126db2288a7edc3946b31d3936e286f5;hp=ef0396f4ccbce2f402a770de3697d8d5d0f37a17;hb=0885acc99dd153f55d07e293b4fbb8aaad10f0d2;hpb=84df20a29292cfb9f52acb0e0a2ebab2b996aa0b diff --git a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/ChoiceReader.java b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/ChoiceReader.java index ef0396f4cc..7422319312 100644 --- a/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/ChoiceReader.java +++ b/opendaylight/netconf/netconf-cli/src/main/java/org/opendaylight/controller/netconf/cli/reader/impl/ChoiceReader.java @@ -13,6 +13,7 @@ import com.google.common.base.Function; import com.google.common.collect.Maps; import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -25,8 +26,10 @@ import org.opendaylight.controller.netconf.cli.io.ConsoleContext; import org.opendaylight.controller.netconf.cli.io.ConsoleIO; import org.opendaylight.controller.netconf.cli.reader.AbstractReader; import org.opendaylight.controller.netconf.cli.reader.ReadingException; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.impl.NodeFactory; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -55,7 +58,7 @@ public class ChoiceReader extends AbstractReader { } @Override - public List> readWithContext(final ChoiceSchemaNode choiceNode) throws IOException, ReadingException { + public List> readWithContext(final ChoiceSchemaNode choiceNode) throws IOException, ReadingException { final Map availableCases = collectAllCases(choiceNode); console.formatLn("Select case for choice %s from: %s", choiceNode.getQName().getLocalName(), formatSet(availableCases.keySet())); @@ -74,19 +77,22 @@ public class ChoiceReader extends AbstractReader { throw new ReadingException(message); } - return readSelectedCase(selectedCase); + return Collections.>singletonList( + ImmutableChoiceNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(choiceNode.getQName())) + .withValue(((Collection) readSelectedCase(selectedCase))).build()); } - protected List> readSelectedCase(final ChoiceCaseNode selectedCase) throws ReadingException { + protected List> readSelectedCase(final ChoiceCaseNode selectedCase) throws ReadingException { // IF there is a case that contains only one Empty type leaf, create the // leaf without question, since the case was selected if (containsOnlyOneEmptyLeaf(selectedCase)) { - final Node newNode = NodeFactory.createImmutableSimpleNode(selectedCase.getChildNodes().iterator() - .next().getQName(), null, null); - return Collections.> singletonList(newNode); + final NormalizedNode newNode = ImmutableLeafNodeBuilder.create() + .withNodeIdentifier(new NodeIdentifier(selectedCase.getChildNodes().iterator().next().getQName())).build(); + return Collections.>singletonList(newNode); } - final List> newNodes = new ArrayList<>(); + final List> newNodes = new ArrayList<>(); for (final DataSchemaNode schemaNode : selectedCase.getChildNodes()) { newNodes.addAll(argumentHandlerRegistry.getGenericReader(getSchemaContext(), getReadConfigNode()).read( schemaNode));