ktorm
ktorm copied to clipboard
Use kapt to generate boilerplate codes.
Consider introducing annotation processor tools to generate boilerplate codes like:
interface Department : Entity<Department> {
companion object : Entity.Factory<Department>()
val id: Int
var name: String
var location: String
}
open class Departments(alias: String?) : Table<Department>("t_department", alias) {
companion object : Departments(null)
override fun aliased(alias: String) = Departments(alias)
val id by int("id").primaryKey().bindTo(Department::id)
val name by varchar("name").bindTo(Department::name)
val location by varchar("location").bindTo(Department::location)
}
It's annoying to write those companion objects and to override aliased functions...
Create an entity like it's a data class.
Now:
Department {
id = 123
name = "tect"
}
Expected:
Department(
id = 123,
name = "tect"
)
Or we can write a compiler plugin? https://www.youtube.com/watch?v=w-GMlaziIyo
这个点非常好,大大简化模板代码。
Something like https://github.com/TouK/krush would be great!