Created
May 29, 2018 06:56
-
-
Save s1monw1/5f167f1517ab6a55cef1b44def9dba73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class PageableDTO(val offset: Int, val limit: Int, val sortBy: String? = null, val ascending: Boolean? = null) | |
fun PageableDTO.injectDefaults() = | |
copy(sortBy = if (sortBy?.isNotEmpty() == true) sortBy else "created_ts", ascending = ascending ?: true) | |
fun main(args: Array<String>) { | |
val pageableDTO = PageableDTO(1, 2) | |
val withDefaults = pageableDTO.injectDefaults() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment