Override properties in enum class


#1

I had some code like this:

interface Assets {
    val fullPath: String
}

enum class MusicAssets(fileName: String) : Assets {
    intro("intro"),
    battleInForest("battle_in_forest");

    override val fullPath: String
    init {
        val prefix = "audio/music/"
        val suffix = ".mp3"
        fullPath= "$prefix$fileName$suffix"
    }
}

The IDEA told me “Accessing non-final property path in constructor” on the fullPath.
Then I added a final on fullPath.

final override val fullPath: String

The IDEA now said “Redundant modality modifier” on the final

Which is right?


#2

It works… I just copy Your code and add the main function with for (m in MusicAssets.values()) {println(m.fullPath)}
Result:
“C:\Program Files\Java\jdk1.8.0_101\bin\java” -Didea.launcher.port=7533 “-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2016.2.2\bin” -Dfile.encoding=windows-1251 -classpath “C:\Program Files\Java\jdk1.8.0_101\jre\lib.(…skipped).;C:\danik_ik\Projects\java\kt_probe\out\production\kt_probe;C:\Users\danik_ik.IdeaIC2016.2\config\plugins\Kotlin\kotlinc\lib\kotlin-runtime.jar;C:\Users\danik_ik.IdeaIC2016.2\config\plugins\Kotlin\kotlinc\lib\kotlin-reflect.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2016.2.2\lib\idea_rt.jar” com.intellij.rt.execution.application.AppMain NnnKt
audio/music/intro.mp3
audio/music/battle_in_forest.mp3

Process finished with exit code 0

What am I doing wrong?