Is there a recommended practice on how to handle the business logic inside a Kotlin Data class? For eg: I have a DTO object thats coming from a REST API like this:
data class ResponseDTO(
@SerializedName("isAuto") val isAuto: Boolean,
@SerializedName("autoStatus") val autoStatus: String
) {
fun getStatus() : String {
if (isAuto) {
if (autoStatus.isNotEmpty()) {
return autoStatus
} else {
return "Default Auto"
}
}
else {
return "Default Manual"
}
}
}
We need to return different Strings based on the values returned so what are the best practices to
- Define the business logic inside the Kotlin data class
- Get the string resources inside the Kotlin data class
This is only an example and not the exact code but our API is returning basic values and we have lot of Business logic to deduce what we want to display in the UI.