import org.opendaylight.yangtools.yang.data.impl.schema.transform.ToNormalizedNodeParserFactory;
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.YangModeledAnyXmlSchemaNode;
/**
*
* Abstract implementation that implements the dispatch conditions. Only requires parsers to be provided.
* The same instance of parser can be provided in case it is immutable.
*/
- public static abstract class BaseNodeParserDispatcher<E> implements NodeParserDispatcher<E> {
+ abstract class BaseNodeParserDispatcher<E> implements NodeParserDispatcher<E> {
private final ToNormalizedNodeParserFactory<E> factory;
protected BaseNodeParserDispatcher(final ToNormalizedNodeParserFactory<E> factory) {
}
@Override
- public final DataContainerChild<?, ?> dispatchChildElement(Object schema, List<E> childNodes) {
- Preconditions.checkArgument(childNodes.isEmpty() == false);
+ public final DataContainerChild<?, ?> dispatchChildElement(final Object schema, final List<E> childNodes) {
+ Preconditions.checkArgument(!childNodes.isEmpty());
if (schema instanceof ContainerSchemaNode) {
return factory.getContainerNodeParser().parse(childNodes, (ContainerSchemaNode) schema);
} else if (schema instanceof LeafListSchemaNode) {
return factory.getLeafSetNodeParser().parse(childNodes, (LeafListSchemaNode) schema);
} else if (schema instanceof ListSchemaNode) {
- return factory.getMapNodeParser().parse(childNodes, (ListSchemaNode) schema);
- } else if (schema instanceof ChoiceNode) {
- return factory.getChoiceNodeParser().parse(childNodes, (ChoiceNode) schema);
+ final ListSchemaNode listSchemaNode = (ListSchemaNode)schema;
+ if (listSchemaNode.getKeyDefinition().isEmpty()) {
+ return factory.getUnkeyedListNodeParser().parse(childNodes, listSchemaNode);
+ } else if (listSchemaNode.isUserOrdered()) {
+ return factory.getOrderedListNodeParser().parse(childNodes, listSchemaNode);
+ } else {
+ return factory.getMapNodeParser().parse(childNodes, listSchemaNode);
+ }
+ } else if (schema instanceof ChoiceSchemaNode) {
+ return factory.getChoiceNodeParser().parse(childNodes, (ChoiceSchemaNode) schema);
} else if (schema instanceof AugmentationSchema) {
return factory.getAugmentationNodeParser().parse(childNodes, (AugmentationSchema) schema);
+ } else if (schema instanceof YangModeledAnyXmlSchemaNode) {
+ return factory.getYangModeledAnyXmlNodeParser().parse(childNodes,(YangModeledAnyXmlSchemaNode)schema);
} else if (schema instanceof AnyXmlSchemaNode) {
return factory.getAnyXmlNodeParser().parse(childNodes,(AnyXmlSchemaNode)schema);
}