aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt4
-rw-r--r--src/test/kotlin/com/romangraef/jrconfig/MainKt.kt3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt b/src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt
index 5874e76..8a9d375 100644
--- a/src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt
+++ b/src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt
@@ -1,6 +1,10 @@
package com.romangraef.jrconfig
+import kotlin.reflect.KProperty
+
interface ConfigVariable<T> {
fun get(): T
fun set(value: T)
+ operator fun getValue(thisRef: Any?, property: KProperty<*>) = get()
+ operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = set(value)
} \ No newline at end of file
diff --git a/src/test/kotlin/com/romangraef/jrconfig/MainKt.kt b/src/test/kotlin/com/romangraef/jrconfig/MainKt.kt
index 504b446..4fa593f 100644
--- a/src/test/kotlin/com/romangraef/jrconfig/MainKt.kt
+++ b/src/test/kotlin/com/romangraef/jrconfig/MainKt.kt
@@ -1,8 +1,11 @@
package com.romangraef.jrconfig
val token = Config.get<String>("token")
+var someOtherOption by Config.get<String>("someOtherOption")
fun main() {
Config.use(FilePropertiesProvider.create("config.properties"))
println(token.get())
+ println(someOtherOption)
+ someOtherOption = "lul"
} \ No newline at end of file