I'd like to provide a pretty name for an enumeration used in my extension point config.
Overriding toString
will show my pretty name in the UI and allow for selection + save, but the dropdown box doesn't load the current value correctly. I think this is because the list of options is derived from the string values which are different than the values stored in the config.json
. For example, selecting SHA-256
will store SHA256
into the config.json
.
Should I be doing something smarter with my Enumeration.Provider
?
@FormCategoryKey("Snmp.config.category.Authentication")
@Label("Authentication Protocol *")
@DescriptionKey("Snmp.config.Authentication.AuthProtocol.Description")
@FormField(FormFieldType.SELECT)
@Enumeration(AuthenticationProtocol.Provider::class)
@Required
val protocol: AuthenticationProtocol,
enum class AuthenticationProtocol(val mappedProtocol: AuthGeneric?, val prettyName: String) {
NONE(null, "None"),
MD5(AuthMD5(), "MD-5"),
SHA1(AuthSHA(), "SHA-1"),
SHA224(AuthHMAC128SHA224(), "SHA-224"),
SHA256(AuthHMAC192SHA256(), "SHA-256"),
SHA384(AuthHMAC256SHA384(), "SHA-384"),
SHA512(AuthHMAC384SHA512(), "SHA-512");
override fun toString(): String {
return prettyName
}
class Provider : Enumeration.Provider {
override fun values(): Array<out Any> {
return AuthenticationProtocol.entries.toTypedArray()
}
}
}