From f01e2b85e61598bfbfdf4c3e55d5ce138886f3c5 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Thu, 8 Jan 2015 17:36:59 +0100
Subject: [PATCH] Switch to options

---
 .../main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala  | 6 +++---
 .../scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala   | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
index 6aa905086..9855e7248 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/utils/ConfigUtils.scala
@@ -58,10 +58,10 @@ object ConfigUtils extends Logging {
    * @param path Nested path to get from map
    * @return Nested map
    */
-  def getMapFromPath(map: Map[String, Any], path: List[String]): Map[String, Any] = {
-    val value = getValueFromPath(map, path) getOrElse { return null }
+  def getMapFromPath(map: Map[String, Any], path: List[String]): Option[Map[String, Any]] = {
+    val value = getValueFromPath(map, path) getOrElse { return None }
     value match {
-      case m: Map[_, _] => m.asInstanceOf[Map[String, Any]]
+      case m: Map[_, _] => Some(m.asInstanceOf[Map[String, Any]])
       case _            => throw new IllegalStateException("Value is not a map: " + value)
     }
   }
diff --git a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala
index 9aa474fa7..f85824aa8 100644
--- a/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala
+++ b/public/biopet-framework/src/test/scala/nl/lumc/sasc/biopet/utils/ConfigUtilsTest.scala
@@ -26,8 +26,8 @@ class ConfigUtilsTest extends TestNGSuite with MockitoSugar with Matchers {
   }
 
   @Test def testGetMapFromPath: Unit = {
-    getMapFromPath(map1, List("dummy")) shouldBe Map("dummy" -> 1)
-    getMapFromPath(map1, List("nested3", "nested2", "nested1")) shouldBe Map("dummy" -> 1)
+    getMapFromPath(map1, List("dummy")) shouldBe Some(Map("dummy" -> 1))
+    getMapFromPath(map1, List("nested3", "nested2", "nested1")) shouldBe Some(Map("dummy" -> 1))
     intercept[IllegalStateException] {
       getMapFromPath(map1, List("dummy", "dummy"))
     }
-- 
GitLab