Created
August 16, 2018 11:16
-
-
Save bekwam/64a796fec2c598c0555b89e57bc11d8b to your computer and use it in GitHub Desktop.
Kotlin Class With Surrogate Key Field
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 ClassWithSurrogateKey(val field1 : String, val field2 : Int) { | |
val id = nextId() // always increasing | |
companion object { | |
private var idgen = 1 // faux static class member | |
fun nextId() = idgen++ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment