Bug 5345: Unable to use get-schema RPC due to unsafe class casting
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / BuilderUtils.java
index 792db8d9c84b8a1a677df8511343fa097565845b..57d33c6442c3bcd9aba524a5158038e821ce71b0 100644 (file)
@@ -790,7 +790,15 @@ public final class BuilderUtils {
         for (TypeDefinition<?> node : nodes) {
             QName qname = QName.create(parentQName, node.getQName().getLocalName());
             SchemaPath schemaPath = parentPath.createChild(qname);
-            result.add(new TypeDefinitionBuilderImpl(moduleName, line, qname, schemaPath, (ExtendedType) node));
+            //Beryllium fix only, using deprecated structures
+            if (node instanceof ExtendedType) {
+                result.add(new TypeDefinitionBuilderImpl(moduleName, line, qname, schemaPath, (ExtendedType) node));
+            } else {
+                ExtendedType.Builder typeBuilder = ExtendedType.builder(node.getQName(), node.getBaseType(),
+                        Optional.fromNullable(node.getDescription()), Optional.fromNullable(node.getReference()),
+                        node.getPath());
+                result.add(new TypeDefinitionBuilderImpl(moduleName, line, qname, schemaPath, typeBuilder.build()));
+            }
         }
         return result;
     }