Skip to content

Commit ec10834

Browse files
authored
Merge pull request #130 from ProjectMapK/remove-ignoreing
Remove `getter-like`/`setter-like` ignore processing.
2 parents 673ae04 + 8cf5887 commit ec10834

File tree

4 files changed

+3
-36
lines changed

4 files changed

+3
-36
lines changed

docs/KogeraSpecificImplementations.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ In `jackson-module-kogera`, there are several intentional design changes that ar
22
This page summarizes them.
33

44
# Common
5-
## Set `Kotlin Property` as positive and ignore functions.
6-
In `jackson-module-kotlin`, functions with getterLike or setterLike names are handled in the same way as `Kotlin Property`.
7-
On the other hand, this implementation causes discrepancies between the `Kotlin` description and the processing results by `Jackson`.
8-
9-
Therefore, `kogera` processes only `Kotlin Property` and excludes other functions from processing.
10-
In addition, `kogera` uses the content defined in `Kotlin` as its name.
11-
12-
These changes make it impossible to manipulate the results using `JvmName`.
13-
145
## Change of `hasRequiredMarker` specification
156
The `KotlinAnnotationIntrospector::hasRequiredMarker` function in `jackson-module-kotlin` has several problems.
167
In `kogera`, the specification has been revised as follows.

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.github.projectmapk.jackson.module.kogera.annotation_introspector
22

3-
import com.fasterxml.jackson.annotation.JsonProperty
43
import com.fasterxml.jackson.databind.JavaType
54
import com.fasterxml.jackson.databind.JsonSerializer
65
import com.fasterxml.jackson.databind.cfg.MapperConfig
@@ -20,11 +19,9 @@ import io.github.projectmapk.jackson.module.kogera.isNullable
2019
import io.github.projectmapk.jackson.module.kogera.isUnboxableValueClass
2120
import io.github.projectmapk.jackson.module.kogera.reconstructClassOrNull
2221
import io.github.projectmapk.jackson.module.kogera.ser.SequenceToIteratorConverter
23-
import io.github.projectmapk.jackson.module.kogera.toSignature
2422
import kotlinx.metadata.KmTypeProjection
2523
import kotlinx.metadata.KmValueParameter
2624
import kotlinx.metadata.jvm.fieldSignature
27-
import kotlinx.metadata.jvm.setterSignature
2825
import java.lang.reflect.Constructor
2926
import java.lang.reflect.Method
3027
import java.lang.reflect.Modifier
@@ -59,23 +56,6 @@ internal class KotlinFallbackAnnotationIntrospector(
5956
else -> null
6057
}
6158

62-
// If it is not a property on Kotlin, it is not used to ser/deserialization
63-
override fun findPropertyAccess(ann: Annotated): JsonProperty.Access? = (ann as? AnnotatedMethod)?.let { _ ->
64-
cache.getJmClass(ann.declaringClass)?.let { jmClass ->
65-
val method = ann.annotated
66-
67-
// By returning an illegal JsonProperty.Access, it is effectively ignore.
68-
when (method.parameters.size) {
69-
0 -> JsonProperty.Access.WRITE_ONLY.takeIf { jmClass.findPropertyByGetter(method) == null }
70-
1 -> {
71-
val signature = method.toSignature()
72-
JsonProperty.Access.READ_ONLY.takeIf { jmClass.properties.none { it.setterSignature == signature } }
73-
}
74-
else -> null
75-
}
76-
}
77-
}
78-
7959
// returns Converter when the argument on Java is an unboxed value class
8060
override fun findDeserializationConverter(a: Annotated): Any? = (a as? AnnotatedParameter)?.let { param ->
8161
findKotlinParameter(param)?.let { valueParameter ->

src/test/kotlin/io/github/projectmapk/jackson/module/kogera/_integration/ser/PropertySerializeTest.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ class PropertySerializeTest {
1515
@Suppress("PropertyName") val `baz-baz`: String,
1616
// https://github.com/FasterXML/jackson-module-kotlin/issues/503
1717
val nQux: Int
18-
) {
19-
// Ignored because it is not a Kotlin property
20-
fun getZzz(): Int = -1
21-
}
18+
)
2219

2320
@Test
2421
fun test() {

src/test/kotlin/io/github/projectmapk/jackson/module/kogera/_ported/test/github/Github464.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class Github464 {
3838
interface IGetter<T> {
3939
val quux: T
4040

41-
val xyzzy: T get() = quux
41+
// see #129
42+
// val xyzzy: T get() = quux
4243
}
4344

4445
class Poko(
@@ -106,7 +107,6 @@ class Github464 {
106107
"1" : null,
107108
"null-key" : null
108109
},
109-
"xyzzy" : 0,
110110
"plugh" : 0
111111
}
112112
""".trimIndent(),
@@ -142,7 +142,6 @@ class Github464 {
142142
"1" : "null-value",
143143
"null-key" : "null-value"
144144
},
145-
"xyzzy" : 0,
146145
"plugh" : 0
147146
}
148147
""".trimIndent(),

0 commit comments

Comments
 (0)