Created
June 5, 2023 09:16
-
-
Save 5AbhishekSaxena/80f9d1e1a54fa2c3fb0055ec70040d34 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
class User private constructor( | |
firstName: String?, | |
// remaining properties… | |
) { | |
val firstName: String | |
// other properties... | |
init { | |
// validations, if any | |
// set values | |
this.firstName = firstName | |
// remaining properties ... | |
} | |
class Builder { | |
private var firstName: String? = null | |
Other Properties | |
Public Setters for the builder | |
// build() that returns the User object. | |
fun build(): User {...} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment