aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--src/main/kotlin/com/romangraef/jrconfig/ConfigVariable.kt4
-rw-r--r--src/test/kotlin/com/romangraef/jrconfig/MainKt.kt3
3 files changed, 12 insertions, 1 deletions
diff --git a/README.md b/README.md
index 4d5f1fa..ed46a2d 100644
--- a/README.md
+++ b/README.md
@@ -21,10 +21,14 @@ public class ConfigurableClass1 {
Kotlin:
```kotlin
val someConfigProp = Config.get<String>("someProp")
+var someOtherOption by Config.get<String>("someOtherOption")
+
fun main() {
Config.use(FilePropertiesProvider.create("config.properties"))
println(someConfigProp.get())
+ println(someOtherOption)
+ someOtherOption = "lul"
}
```
@@ -59,7 +63,7 @@ repositories {
}
dependencies {
- implementation("com.github.romangraef", "jrconfig", "v0.3")
+ implementation("com.github.romangraef", "jrconfig", "v0.4")
}
```
The version can be either a git shortref, or a [tag](https://github.com/romangraef/jrconfig/tags).
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