David Kubecka
05/22/2023, 2:27 PMinterface CellMapping {
val sheetAddress: String
val cellAddress: CellAddress
get() = CellAddress(sheetAddress)
}
private enum class Cells(
override val sheetAddress: String,
override val sheetType: SheetType,
) : CellMapping
This works but the CellAddress is constructed every time the cellAddress
prop is accessed. Is there any way to avoid that?Casey Brooks
05/22/2023, 2:34 PMcellAddress
.
Typically, you would address this by using an abstract or open class instead of interface, but enums cannot extend other classes so that doesn’t work here.David Kubecka
05/22/2023, 2:36 PMenums cannot extend other classesYeah, forgot to add this (known) detail. Btw what is the reason for that?
dmitriy.novozhilov
05/22/2023, 2:37 PMjava.langEnum
, and it's not allowed for class to have several super classesAdam S
05/22/2023, 2:52 PMephemient
05/22/2023, 4:27 PMenum class Cells(
override val sheetAddress: String,
) : CellMapping {
override val cellAddress by lazy {
CellAddress(sheetAddress)
}
}
Casey Brooks
05/22/2023, 4:33 PMinterface CellMapping {
val sheetAddress: String
val cellAddress: CellAddress
}
class CellMappingDelegate(
override val sheetAddress: String
) : CellMapping {
override val cellAddress: CellAddress = CellAddress(sheetAddress)
}
private enum class Cells(
sheetAddress: String,
) : CellMapping by CellMappingDelegate(sheetAddress)
David Kubecka
05/23/2023, 8:36 AM