Add Schema::nodeType method

Change-Id: Id17e00ebef4820abae3b66d2e262be4b16c7a672
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index 47e0884..aae6b84 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -10,8 +10,6 @@
 #include "static_schema.hpp"
 #include "utils.hpp"
 
-InvalidNodeException::~InvalidNodeException() = default;
-
 StaticSchema::StaticSchema()
 {
     m_nodes.emplace("/", std::unordered_map<std::string, NodeType>());
@@ -284,3 +282,37 @@
     }
     return res;
 }
+
+yang::NodeTypes StaticSchema::nodeType(const schemaPath_& location, const ModuleNodePair& node) const
+{
+    std::string locationString = pathToSchemaString(location, Prefixes::Always);
+    auto fullName = fullNodeName(location, node);
+    try {
+        auto targetNode = children(locationString).at(fullName);
+
+        if (targetNode.type() == typeid(yang::container)) {
+            if (boost::get<yang::container>(targetNode).m_presence == yang::ContainerTraits::Presence) {
+                return yang::NodeTypes::PresenceContainer;
+            }
+            return yang::NodeTypes::Container;
+        }
+
+        if (targetNode.type() == typeid(yang::list)) {
+            return yang::NodeTypes::List;
+        }
+
+        if (targetNode.type() == typeid(yang::leaf)) {
+            return yang::NodeTypes::Leaf;
+        }
+
+        throw std::runtime_error{"YangSchema::nodeType: unsupported type"};
+
+    } catch (std::out_of_range&) {
+        throw InvalidNodeException();
+    }
+}
+
+yang::NodeTypes StaticSchema::nodeType([[maybe_unused]] const std::string& path) const
+{
+    throw std::runtime_error{"Internal error: StaticSchema::nodeType(std::string) not implemented. The tests should not have called this overload."};
+}