-
-
Save 5AbhishekSaxena/66b709a2ef187fe6372ad519ccd72efe 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 Company( | |
name: String? | |
) { | |
val name: String | |
init { | |
if (name.isNullOrBlank()) | |
throw IllegalArgumentException("Name must not be null or blank.") | |
this.name = name | |
} | |
class Builder { | |
private var name: String? = null | |
fun setName(name: String) = apply { | |
this.name = name | |
} | |
fun build(): Company { | |
return Company(name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment