I have a class which is having multiple companion objects which are lists of strings. In another class (Activity) I am having a string which can have name of any of the companion object. Is there a way of accessing other class's companion object without If/Else statements.
DataLists
class ProjectDataLists {
companion object {
var Countries: List<String> = listOf(
"USA",
"Canada",
"Australia",
"UK"
)
var Cars: List<String> = listOf(
"Toyota",
"Suzuki",
"Honda",
"Ford"
)
}
}
Activity Class
var IntentVariable: String = "Countries" //This is an Intent variable (extra) from another activity
var DataToBeFetched : List<String>? = null
if (IntentVariable == "Countries")
{
DataToBeFetched = ProjectDataLists.Countries
}
else if (IntentVariable == "Cars")
{
DataToBeFetched = ProjectDataLists.Cars
}
I want last part of Activity class to be done without if/else