
de.gesellix.docker.compose.adapters.ReflectionUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docker-compose Show documentation
Show all versions of docker-compose Show documentation
A Docker compose v3 abstraction for the JVM
The newest version!
package de.gesellix.docker.compose.adapters
import kotlin.reflect.KMutableProperty
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.memberProperties
fun readProperty(instance: Any, propertyName: String): R {
val clazz = instance.javaClass.kotlin
@Suppress("UNCHECKED_CAST")
return clazz.declaredMemberProperties.first { it.name == propertyName }.get(instance) as R
}
fun writeProperty(instance: Any, propertyName: String, value: Any?) {
val clazz = instance.javaClass.kotlin
@Suppress("UNCHECKED_CAST")
return clazz.memberProperties
.filterIsInstance>()
.first { it.name == propertyName }.setter.call(instance, value)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy