Created
April 25, 2019 02:19
-
-
Save rustyrazorblade/7e113c97e3bb32b626f8d489542e1c0f to your computer and use it in GitHub Desktop.
maybe gross? not sure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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