Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rustyrazorblade/7e113c97e3bb32b626f8d489542e1c0f to your computer and use it in GitHub Desktop.
Save rustyrazorblade/7e113c97e3bb32b626f8d489542e1c0f to your computer and use it in GitHub Desktop.
maybe gross? not sure
fun applyDynamicSettings(workloadParameters: Map<String, String>) {
for((key, value) in workloadParameters) {
var prop = getProperty(instance, key) as KMutableProperty<*>
val annotation = prop.findAnnotation<WorkloadParameter>()
log.debug("Annotation for $key found: $annotation")
// Int
if(prop.returnType.isSubtypeOf(Int::class.createType())) {
log.debug("Found the type, we have an int, setting the value")
prop.setter.call(instance, value.toInt())
continue
}
// String
if(prop.returnType.isSubtypeOf(String::class.createType())) {
log.debug("Found the type, we have a String, setting the value")
prop.setter.call(instance, value)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment