Scala: force method calls in class hierarchy
问题 I have a hierarchy of ConfigBuilder classes which have the role of creating Config instances. My superclass is an AbstractConfigBuilder which has a method build . I want that build always calls a method validate before actually building the object. So, in the abstract super class I have val commonField: String //one of many fields common to all the hierarchy abstract def build: Config //building logic left to the subclasses def validate: Boolean = { // here some common checks commonField.size