I have the following code in java:
Enum getEnumValue(Class<?> enumClass, String value) {
return Enum.valueOf((Class<Enum>) enumClass, value);
}
How to rewrite this in Kotlin?
Update
enumValueOf<>()
function is not applicable in this case because I don't know the actual type parameter, I only have a Class<?>
object with unknown type (Class<*>
in kotlin) and a name string. The Class is known to be enum: Class.isEnum
returns true. Using these two inputs, the java code above allows to obtain the value of the enum with a raw type. That's just what I need because I'm not interested in the specific type of the enum. But I can't figure out how to get the same result in kotlin.