diff options
Diffstat (limited to 'src/main/scala/xyz/driver/pdsuicommon')
-rw-r--r-- | src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala b/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala index 4e98f40..36c3de7 100644 --- a/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala +++ b/src/main/scala/xyz/driver/pdsuicommon/domain/FuzzyValue.scala @@ -10,21 +10,31 @@ object FuzzyValue { case object No extends FuzzyValue case object Maybe extends FuzzyValue - val All: Set[FuzzyValue] = Set(Yes, No, Maybe) + private val yes = "Yes" + private val no = "No" + private val maybe = "Maybe" - def fromBoolean(x: Boolean): FuzzyValue = if (x) Yes else No + val All: Set[FuzzyValue] = + Set(Yes, No, Maybe) - implicit def toPhiString(x: FuzzyValue): PhiString = Unsafe(Utils.getClassSimpleName(x.getClass)) + def fromBoolean(x: Boolean): FuzzyValue = + if (x) Yes else No + + implicit def toPhiString(x: FuzzyValue): PhiString = + Unsafe(Utils.getClassSimpleName(x.getClass)) val fromString: PartialFunction[String, FuzzyValue] = { - case "Yes" => Yes - case "No" => No - case "Maybe" => Maybe + case fuzzy => + fuzzy.toLowerCase.capitalize match { + case `yes` => Yes + case `no` => No + case `maybe` => Maybe + } } def valueToString(x: FuzzyValue): String = x match { - case Yes => "Yes" - case No => "No" - case Maybe => "Maybe" + case Yes => `yes` + case No => `no` + case Maybe => `maybe` } } |