https://kotlinlang.org logo
Title
m

miha-x64

11/06/2018, 5:31 PM
Are there any ways to achieve exhaustiveness, but enums or sealed classes? I have a bunch of objects and want to provide each of them with some data. (Certainly, I've got DTO schema and want to add platform-specific (SQL-specific, JSON-specific, etc) metadata)
s

Shawn

11/06/2018, 5:38 PM
how do you plan on using this? can you provide a hypothetical
when
statement or another snippet that would take advantage of what you're asking for?
m

miha-x64

11/06/2018, 6:14 PM
Schema sample: https://github.com/Miha-x64/reactive-properties/blob/f9381419ac638c31f4e3f51bc4d856ce4c8ee79e/logic-sample/src/main/kotlin/net/aquadc/propertiesSampleLogic/sql/schema.kt#L27 Metadata sample:
fun jsonMeta(field: FieldDef<User, *>) = when (field) {
    Name -> OverrideName(Prefix("user"))
    Surname -> OverrideName(Prefix("user"))
}