Skip to content

Instantly share code, notes, and snippets.

@seoft
Created November 13, 2021 08:53
Show Gist options
  • Save seoft/0b348d9ab2d9e7a06801e54602829c80 to your computer and use it in GitHub Desktop.
Save seoft/0b348d9ab2d9e7a06801e54602829c80 to your computer and use it in GitHub Desktop.
fun from(responseModels: List<ResponseModel>): List<NormalUiModel> {
return responseModels.map { from(it) }
}
fun from(responseModel: ResponseModel): NormalUiModel {
return responseModel.run {
when (type) {
ResponseType.MONITOR -> NormalUiModel.Monitor(id, price, inch ?: 0f)
ResponseType.MOUSE -> NormalUiModel.Mouse(id, price, buttonCount ?: 0)
ResponseType.PHONE -> NormalUiModel.Phone(id, price, os ?: "")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment