From bbc212798caacb0bdc995b9f7f1211b60c8587b9 Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Thu, 26 Jun 2014 10:28:49 +0200 Subject: [PATCH] Added default flag --- .../sasc/biopet/core/config/ConfigValue.scala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/ConfigValue.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/ConfigValue.scala index 3fef4e9fb..3963a683f 100644 --- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/ConfigValue.scala +++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/config/ConfigValue.scala @@ -1,6 +1,6 @@ package nl.lumc.sasc.biopet.core.config -class ConfigValue(val requestIndex:ConfigValueIndex, val foundIndex:ConfigValueIndex, val value:Any) { +class ConfigValue(val requestIndex:ConfigValueIndex, val foundIndex:ConfigValueIndex, val value:Any, val default: Boolean) { def getString = Configurable.any2string(value) def getInt = Configurable.any2int(value) def getDouble = Configurable.any2double(value) @@ -8,14 +8,22 @@ class ConfigValue(val requestIndex:ConfigValueIndex, val foundIndex:ConfigValueI def getMap = Configurable.any2map(value) override def toString: String = { - var output = "requestIndex = " + requestIndex - if (foundIndex == null) output += "'not foundin config, used default'" - else output += ", foundIndex = " + foundIndex + var output = "key = " + requestIndex.key output += ", value = " + value + output += ", requestIndex = (" + requestIndex + ")" + if (foundIndex == null && !default) output += ", found on root of config" + else if(!default) output += ", foundIndex = (" + foundIndex + ")" + else output += ", default value is used" + return output } } object ConfigValue { - def apply(requestIndex:ConfigValueIndex, foundIndex:ConfigValueIndex, value:Any) = new ConfigValue(requestIndex,foundIndex,value) + def apply(requestIndex:ConfigValueIndex, foundIndex:ConfigValueIndex, value:Any) = { + new ConfigValue(requestIndex,foundIndex,value, false) + } + def apply(requestIndex:ConfigValueIndex, foundIndex:ConfigValueIndex, value:Any, default:Boolean) = { + new ConfigValue(requestIndex,foundIndex,value, default) + } } -- GitLab