MigrateFrom

annotation class MigrateFrom(val oldKeys: String)

Specifies one or more legacy YAML keys that should be migrated to the annotated field when loading a configuration file.

Use this annotation when renaming or reorganizing configuration fields to maintain backward compatibility with existing config files. During deserialization, if the current key is absent but one of the old keys is present, the value is read from the old key. Multiple old keys are checked in the order provided.

Usage:

data class ServerConfig(
@MigrateFrom("server-name", "serverName")
val name: String = "default",

@MigrateFrom("max-players")
val maxPlayers: Int = 100
)

Since

1.0

Properties

Link copied to clipboard
val oldKeys: Array<out String>

One or more legacy key names to check during deserialization, in priority order.