Fix falling empty maps back to their schema's default values

This commit is contained in:
2020-03-21 13:30:47 +01:00
parent 8511356191
commit a30a7fc42a
3 changed files with 4 additions and 7 deletions

View File

@@ -17,8 +17,4 @@ class ConfigMap(private val map: Map<Value, Value>) {
fun containsKey(key: String): Boolean {
return raw.containsKey(key)
}
companion object {
val EMPTY = ConfigMap(emptyMap())
}
}

View File

@@ -36,4 +36,6 @@ class ConfigMapSchema {
else Value.string(name) to value
}.toMap())
}
fun empty(): ConfigMap = parse(Value.map(emptyMap()))
}

View File

@@ -13,7 +13,6 @@ import io.smnp.type.matcher.Matcher.Companion.listOfMatchers
import io.smnp.type.matcher.Matcher.Companion.mapOfMatchers
import io.smnp.type.matcher.Matcher.Companion.ofType
import io.smnp.type.model.Value
import io.smnp.util.config.ConfigMap
import io.smnp.util.config.ConfigMapSchema
@@ -47,7 +46,7 @@ class MidiFunction : Function("midi") {
throw CustomException("MIDI standard supports max to 16 channels and that number has been exceeded")
}
Midi.with(ConfigMap.EMPTY).play(unwrappedLines)
Midi.with(schema.empty()).play(unwrappedLines)
Value.void()
}
@@ -74,7 +73,7 @@ class MidiFunction : Function("midi") {
throw CustomException("MIDI standard supports max to 16 channels and that number has been exceeded")
}
Midi.with(ConfigMap.EMPTY).play(unwrappedChannels)
Midi.with(schema.empty()).play(unwrappedChannels)
Value.void()
}