Skip to content

Commit

Permalink
Issue #356 Demangling kotlin getter
Browse files Browse the repository at this point in the history
  • Loading branch information
elektro-wolle authored and dinomite committed Oct 13, 2020
1 parent 4a91e3a commit f240c02
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.introspect.Annotated
import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor
import com.fasterxml.jackson.databind.introspect.AnnotatedField
import com.fasterxml.jackson.databind.introspect.AnnotatedMember
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector
import com.fasterxml.jackson.databind.util.BeanUtil
Expand All @@ -25,12 +26,24 @@ import kotlin.reflect.jvm.javaType
import kotlin.reflect.jvm.kotlinFunction

internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val cache: ReflectionCache, val ignoredClassesForImplyingJsonCreator: Set<KClass<*>>) : NopAnnotationIntrospector() {
/*
override public fun findNameForDeserialization(annotated: Annotated?): PropertyName? {
// This should not do introspection here, only for explicit naming by annotations

/**
* resolve the name of the property, if not given otherwise.
*/
override fun findNameForSerialization(a: Annotated?): PropertyName? {
if (a is AnnotatedMethod) {
if (a.name.startsWith("get") &&
a.name.contains('-') &&
a.parameterCount == 0) {
return PropertyName(a.name.substringAfter("get").decapitalize().substringBefore('-'))
} else if (a.name.startsWith("is") &&
a.name.contains('-') &&
a.parameterCount == 0) {
return PropertyName(a.name.substringAfter("is").decapitalize().substringBefore('-'))
}
}
return null
}
*/

// since 2.4
override fun findImplicitPropertyName(member: AnnotatedMember): String? {
Expand Down

0 comments on commit f240c02

Please sign in to comment.