I have a hierarchy of data classes:
SchoolWorker / \ Teacher Principle
data class SchoolWorker(val id: Long, val name: String) data class Teacher(val className:String) data class Principle(val numberOfReports:Int)
I thought to use
data class but it does not really work. If SchoolWorker is data class, then all children needs to pass its fields, but if children are data classes, its constructor can only have fields so it is not clear how to pass values to super constructor.
Of course I can give up on data classes and just use classes but, then I loose equals and hashCode, and now I need to generate them which looks ugly compare to lombok+java.
Is there a way to model domain objects as hierarchy of data classes?