enumValueOrNull

Returns the enum value if this is an EnumValue, null otherwise. The type is erased to Enum<*> since the actual type is not known at compile time.