Skip to content

Instantly share code, notes, and snippets.

@shubhra02
Last active June 17, 2017 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shubhra02/847edf7f9bbfc73693a4755ef3ffcc96 to your computer and use it in GitHub Desktop.
Save shubhra02/847edf7f9bbfc73693a4755ef3ffcc96 to your computer and use it in GitHub Desktop.
Type Safe Code
import com.typesafe.config._
case class Employee(config: Config) {
val jobTitle = config.getString("jobTitle")
object company {
val companyName = config.getString("company.companyName")
val place = config.getString("company.place")
}
}
val config = ConfigFactory.parseString(
"""
|se.typesafe.example {
| jobTitle = "Software consultant"
| company {
| companyName = "Knoldus"
| place = "Noida"
| }
|}
""".stripMargin
)
val employee = Employee(config.getConfig("se.typesafe.example"))
employee.jobTitle
// res0: String = Software consultant
employee.company.companyName
// res1: String = Knoldus
employee.company.place
// res2: String = Noida
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment