Fixed bugs in parsing enumeration, augment, identity.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / model / parser / util / ParserUtils.java
index f533b8e6d7e0a5f906d2bf75097766202503ccfd..e7775ce73470b0435d62520be78d8e412504b190 100644 (file)
@@ -11,6 +11,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
 import org.opendaylight.controller.yang.model.api.MustDefinition;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
@@ -27,6 +28,7 @@ import org.opendaylight.controller.yang.model.parser.builder.impl.ContainerSchem
 import org.opendaylight.controller.yang.model.parser.builder.impl.LeafListSchemaNodeBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.LeafSchemaNodeBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.ListSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;
 
 public final class ParserUtils {
@@ -34,6 +36,32 @@ public final class ParserUtils {
     private ParserUtils() {
     }
 
+    /**
+     * Get module import referenced by given prefix.
+     *
+     * @param builder
+     *            module to search
+     * @param prefix
+     *            prefix associated with import
+     * @return ModuleImport based on given prefix
+     */
+    public static ModuleImport getModuleImport(final ModuleBuilder builder,
+            final String prefix) {
+        ModuleImport moduleImport = null;
+        for (ModuleImport mi : builder.getModuleImports()) {
+            if (mi.getPrefix().equals(prefix)) {
+                moduleImport = mi;
+                break;
+            }
+        }
+        return moduleImport;
+    }
+
+    /**
+     * Parse uses path.
+     * @param usesPath as String
+     * @return SchemaPath from given String
+     */
     public static SchemaPath parseUsesPath(final String usesPath) {
         final boolean absolute = usesPath.startsWith("/");
         final String[] splittedPath = usesPath.split("/");