Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Created July 21, 2022 18:26
Show Gist options
  • Save rubenquadros/b33ddf14c290d9b944d6fee5e8ef5fc5 to your computer and use it in GitHub Desktop.
Save rubenquadros/b33ddf14c290d9b944d6fee5e8ef5fc5 to your computer and use it in GitHub Desktop.
Persisting the plugin settings state
@State(
name = "com.ruben.codespector.settings.InspectionSettingState",
storages = [Storage("Codespector.xml")]
)
class InspectionSettingState :
PersistentStateComponent<InspectionSettingState> {
var parser: Parser = Parser.GSON
override fun getState(): InspectionSettingState {
return this
}
override fun loadState(state: InspectionSettingState) {
XmlSerializerUtil.copyBean(state, this)
}
}
enum class Parser(val annotation: String) {
GSON("SerializedName"),
MOSHI("Json"),
KOTLINX_SERIALIZATION("SerialName")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment