returnType = Types.listTypeFor(referencedTypes.get(dataNode.getPath()));
}
if (returnType == null) {
- returnType = resolveTypeFromDataSchemaNode(dataNode);
+ returnType = resolveTypeFromDataSchemaNode(dataNode, inGrouping);
}
Preconditions.checkArgument(returnType != null, "Failed to find leafref target: %s in module %s (%s)",
strXPath, this.getParentModule(parentNode).getName(), parentNode.getQName().getModule(), this);
* @param dataNode contains information about YANG type
* @return JAVA <code>Type</code> representation of <code>dataNode</code>
*/
- private Type resolveTypeFromDataSchemaNode(final SchemaNode dataNode) {
+ private Type resolveTypeFromDataSchemaNode(final SchemaNode dataNode, final boolean inGrouping) {
Type returnType = null;
if (dataNode != null) {
if (dataNode instanceof LeafSchemaNode) {
final LeafSchemaNode leaf = (LeafSchemaNode) dataNode;
final TypeDefinition<?> type = CompatUtils.compatType(leaf);
- returnType = javaTypeForSchemaDefinitionType(type, leaf);
+ returnType = javaTypeForSchemaDefinitionType(type, leaf, inGrouping);
} else if (dataNode instanceof LeafListSchemaNode) {
final LeafListSchemaNode leafList = (LeafListSchemaNode) dataNode;
- returnType = javaTypeForSchemaDefinitionType(leafList.getType(), leafList);
+ returnType = javaTypeForSchemaDefinitionType(leafList.getType(), leafList, inGrouping);
}
}
return returnType;
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.mdsal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Collection;
+import org.junit.Test;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+
+/**
+ * Test specific combination of leafrefs, grouping and relative paths.
+ */
+public class Mdsal519Test {
+
+ @Test
+ public void testNestedLeafref2() {
+ final Collection<Type> types = new BindingGeneratorImpl().generateTypes(
+ YangParserTestUtils.parseYangResource("/mdsal-519/specific-grouping-leafref.yang"));
+ assertNotNull(types);
+ assertEquals(4, types.size());
+ }
+}
--- /dev/null
+module specific-grouping-leafref {
+
+ namespace "odl:test:leafref:grouping:nested";
+ prefix "gl";
+ revision 2020-02-28;
+
+ container container-top {
+ leaf leaf-1 {
+ type string;
+ }
+ uses grouping-leafref;
+ }
+
+ grouping grouping-leafref {
+ container nested-container {
+ leaf leafref-1 {
+ type leafref {
+ path "../leafref-2";
+ }
+ }
+
+ leaf leafref-2 {
+ type leafref {
+ path "../../leaf-1";
+ }
+ }
+ }
+ }
+
+}