Skip to content
Snippets Groups Projects
Commit a4be2bd4 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Refactor getValueFromPath

parent 3ae0c6b2
No related branches found
No related tags found
No related merge requests found
......@@ -73,16 +73,12 @@ object ConfigUtils extends Logging {
* @return Some(value) or None if not found
*/
def getValueFromPath(map: Map[String, Any], path: List[String]): Option[Any] = {
Some(path.foldLeft(map.asInstanceOf[Any])((m, s) => {
m match {
case map: Map[_, _] => {
val mp = map.asInstanceOf[Map[String, Any]]
if (!mp.contains(s)) return None
mp(s)
}
case _ => return None
}
}))
val value = map.get(path.head)
if (path.tail == Nil || value == None) value
else value.get match {
case map: Map[_, _] => getValueFromPath(map.asInstanceOf[Map[String, Any]], path.tail)
case _ => None
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment