Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

fix #1191 master #1195

Merged
merged 1 commit into from
Mar 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/main/java/tornadofx/Component.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,31 @@ class ConfigProperties(val configurable: Configurable) : Properties(), Closeable
val value = pair.second.let {
(it as? JsonModel)?.toJSON()?.toString() ?: it.toString()
}
set(pair.first, value)
setProperty(pair.first, value)
}
}

operator fun set(key: String, value: String) {
setProperty(key, value)
}

operator fun set(key: String, value: Boolean) {
setProperty(key, value.toString())
}

operator fun set(key: String, value: Double) {
setProperty(key, value.toString())
}

operator fun set(key: String, value: Int) {
setProperty(key, value.toString())
}

operator fun set(key: String, value: Any?) {
if (value == null) remove(key)
else setProperty(key, (value as? JsonModel)?.toJSON()?.toString() ?: value.toString())
}

fun string(key: String): String? = getProperty(key)
fun string(key: String, defaultValue: String): String = getProperty(key, defaultValue)
fun boolean(key: String): Boolean? = getProperty(key)?.toBoolean()
Expand Down