December 2017
Intermediate to advanced
322 pages
7h 3m
English
Other than XML, we can also define Spring configuration through annotations in a POJO class, which will not be used as a bean. In the previous section, we took Employee task example; let's now take the Student-Assignment example, a similar one. However, this time, we will not use interfaces; instead, we will directly use classes.
So, here is the Assignment class that takes a lambda as a constructor parameter:
class Assignment(val task:(String)->Unit) {
fun performAssignment(assignmentDtl:String) {
task(assignmentDtl)
}
}
This class takes a lambda as task, to execute it later, inside the performAssignment() method. Here is the Student class that takes Assignment as a property:
class Student(val assignment: ...
Read now
Unlock full access