This file contains hidden or 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
| // this won't compile | |
| trait Language(name: String) | |
| // Use abstract class when needs to have constrctor arguments | |
| abstract class Language(name: String) |
This file contains hidden or 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
| trait Language { | |
| // abstract | |
| var name: String | |
| // concrete | |
| val maxUsage = 10 | |
| // abstract | |
| def lang(): Unit | |
This file contains hidden or 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
| trait Language { | |
| def lang(): Unit | |
| } | |
| trait Functional extends Language { | |
| override def lang() { | |
| println("Functional") | |
| } | |
| } |
This file contains hidden or 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
| trait Lambda { | |
| val l = "Lambda" | |
| } | |
| trait Calculus { | |
| this: Lambda => | |
| val c = "Calculus" | |
| val lc = l + c | |
| } |
This file contains hidden or 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
| trait Lambda { | |
| val l = "Lambda" | |
| } | |
| trait Calculus extends Lambda { | |
| val c = "Calculus" | |
| val lc = l + c | |
| } |
This file contains hidden or 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
| trait EmployeeDbComp { | |
| val employeeDb: EmployeeDb | |
| trait EmployeeDb { | |
| def createEmployee(employee: Employee) | |
| def getEmployee(empId: Int): Employee | |
| } | |
| } |
This file contains hidden or 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
| trait CassandraEmployeeDbComp extends EmployeeDbComp { | |
| this: CakezCassandraCluster => | |
| val employeeDb = new CassandraEmployeeDb | |
| class CassandraEmployeeDb extends EmployeeDb { | |
| def logger = LoggerFactory.getLogger(this.getClass) |
This file contains hidden or 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
| trait EmployeeServiceComp { | |
| val Service: EmployeeService | |
| trait EmployeeService { | |
| def POST(employee: Employee): Future[Unit] | |
| def GET(id: Int): Future[Employee] | |
| } | |
| } |
This file contains hidden or 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
| trait SprayEmployeeServiceCompImpl extends EmployeeServiceComp with Configuration { | |
| this: CakezActorSystem => | |
| val employeeService = new SprayEmployeeService | |
| class SprayEmployeeService extends EmployeeService { | |
| def logger = LoggerFactory.getLogger(this.getClass) |
This file contains hidden or 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 EmployeeHandler { | |
| this: EmployeeDbComp with EmployeeServiceComp => | |
| def logger = LoggerFactory.getLogger(this.getClass) | |
| def createEmployee(inputEmp: String): Employee = { | |
| // inputEmp comes as 'emp_id name department' | |
| val tokens = inputEmp.split(" ") |