groostav
10/04/2019, 9:30 PMvalue: string and a KPropoperty1<*, T>, and I'm certain that the value is a `toString()`'d version of T and that T is a common value type (eg String, Double, or enum class). Is there a handy way for me to convert from my value to an instance of the `KProperty`'s return type? I can write the switch but I sorta feel like somebody should've handled this for me.
I've got both guava and apache commons on my classpathgroostav
10/04/2019, 9:37 PMfun KType.fromString(valueString: String) = when(val typeClassifier = classifier){
Double::class -> {
}
String::class -> {
}
is KClass<*> -> {
if(Enum::class.isSuperclassOf(typeClassifier)){
}
TODO()
}
else -> TODO("$valueString as $typeClassifier")
}groostav
10/04/2019, 9:37 PMCasey Brooks
10/04/2019, 10:22 PMtoString. You could have it return whatever you want, and in many cases toString is intended to return a human-readable String, but not a machine-readable one.Casey Brooks
10/04/2019, 10:22 PMgroostav
10/04/2019, 10:27 PMgroostav
10/04/2019, 10:27 PMgroostav
10/04/2019, 10:28 PMEnum.valueOf() and enum.toString() --assuming of course you have some side-channel to keep schema (IE the typekarelpeeters
10/04/2019, 11:22 PM