Open hajdamak opened 3 months ago
I am not 100% sure if this can be done reliably, but if so, sounds like a reasonable idea.
I believe naming conventions wrt Enum is somewhat controversial. Here is reference to discussion in Kotlin.
As far as I know it is conventional to use
So it might be safer off to provide extension points instead of declaring what Enum naming would be. But as @cowtowncoder mentioned, idk how it could be reliable, technically, since now we would have naming strategies two-ways, in-and-out.
Sounds like something that https://github.com/FasterXML/jackson-module-kotlin can/should(?) support out-of-the-box:
internal class KotlinAnnotationIntrospector(...) {
...
override fun findEnumNamingStrategy(config: MapperConfig<*>, ac: AnnotatedClass): Any? {
return PascalCaseOrCamelCaseStrategy()
}
}
@yihtserns Perhaps, although if so, should only apply to Kotlin Enum types? And be configurable to allow disabling such logic.
...should only apply to Kotlin Enum types?
I think so far nobody from Java side has ever requested such thing, right? The reason this issue was created is because only Kotlin side has such "double standard". 🤐
EDIT: Oh you mean findEnumNamingStrategy
should only return PascalCaseOrCamelCaseStrategy
if the AnnotatedClass
method arg is an enum class generated from Kotlin source code.
UPDATE: E.g.:
internal class KotlinAnnotationIntrospector(...) {
...
override fun findEnumNamingStrategy(config: MapperConfig<*>, ac: AnnotatedClass): Any? {
if (ac.annotated.isKotlinClass()) {
return PascalCaseOrCamelCaseStrategy()
}
return null
}
}
Right, if there are reliable means to detect that information. Similar to how Kotlin special sauce avoided (I think?) for POJOs.
Is your feature request related to a problem? Please describe.
Currently
CamelCaseStrategy
inEnumNamingStrategies
assumes that enum entires in source code are named using UPPER_SNAKE_CASE convention, for example:enum Size { VERY_BIG }
. However in Kotlin quite often UpperCamelCase is used, for exampleenum class Size { VeryBig }
.CamelCaseStrategy
inEnumNamingStrategies
does not work with such a naming.Describe the solution you'd like
Strategies in
EnumNamingStrategies
should work with enum entries written in code using different naming conventions like UpperCamelCase .Usage example
No response
Additional context
No response