Skip to content

Commit 7e55df1

Browse files
committed
Add handling so that an unboxed getter is used as is if JsonUnbox is specified.
1 parent b593766 commit 7e55df1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/kotlin/io/github/projectmapk/jackson/module/kogera/annotation_introspector/KotlinFallbackAnnotationIntrospector.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.util.Converter
1212
import io.github.projectmapk.jackson.module.kogera.KotlinDuration
1313
import io.github.projectmapk.jackson.module.kogera.ReflectionCache
1414
import io.github.projectmapk.jackson.module.kogera.ValueClassUnboxConverter
15+
import io.github.projectmapk.jackson.module.kogera.annotation.JsonUnbox
1516
import io.github.projectmapk.jackson.module.kogera.deser.CollectionValueStrictNullChecksConverter
1617
import io.github.projectmapk.jackson.module.kogera.deser.MapValueStrictNullChecksConverter
1718
import io.github.projectmapk.jackson.module.kogera.isNullable
@@ -83,7 +84,12 @@ internal class KotlinFallbackAnnotationIntrospector(
8384
KotlinDurationValueToJavaDurationConverter
8485
}
8586
} else {
86-
cache.getValueClassBoxConverter(a.rawReturnType, it)
87+
// If JsonUnbox is specified, the unboxed getter is used as is.
88+
if (a.hasAnnotation(JsonUnbox::class.java) || it.getAnnotation(JsonUnbox::class.java) != null) {
89+
null
90+
} else {
91+
cache.getValueClassBoxConverter(a.rawReturnType, it)
92+
}
8793
}
8894
}
8995
is AnnotatedClass -> lookupKotlinTypeConverter(a)

0 commit comments

Comments
 (0)