Amir H. Ebrahimnezhad
08/21/2024, 3:11 PMSam
08/21/2024, 3:14 PMsealed interface AorB
enum class A: AorB { a, b, c }
enum class B: AorB { x, y, z }
Amir H. Ebrahimnezhad
08/21/2024, 3:16 PMSam
08/21/2024, 3:18 PMAmir H. Ebrahimnezhad
08/21/2024, 3:19 PMAmir H. Ebrahimnezhad
08/21/2024, 3:21 PMpackage core.definitions.boson
import core.definitions.ParticleType
import core.definitions.attrs.ColorCharge
import core.definitions.attrs.ElectricCharge
import core.definitions.attrs.Spin
import core.utils.idGen
interface Boson : ParticleType {
val type: BosonType
val mass: Double
val electricCharge: ElectricCharge
val colorCharge: ColorCharge
val spin: Spin
get() = Spin.One
val id: Long
get() = idGen.incrementAndGet()
}
And The sealed interface is in
package core.definitions
sealed interface ParticleType
I'm getting an error from intelliJ to move Boson into the defnitions package directory.Sam
08/21/2024, 3:21 PMsealed
keyword and just use a normal interface, but then you'll lose the ability to have an exhaustive when
over both enums.Amir H. Ebrahimnezhad
08/21/2024, 3:36 PM