Skip to content

Commit 0566686

Browse files
authored
Merge pull request #283 from ProjectMapK/import-2.18
Import 2.18 and refactors
2 parents 93948b0 + a02189a commit 0566686

File tree

7 files changed

+63
-5
lines changed

7 files changed

+63
-5
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public class KotlinModule private constructor(
9393
}
9494

9595
public companion object {
96-
@Suppress("ConstPropertyName")
9796
private const val serialVersionUID = 3L
9897
}
9998

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import java.util.Optional
1010
internal class ReflectionCache(initialCacheSize: Int, maxCacheSize: Int) : Serializable {
1111
companion object {
1212
// Increment is required when properties that use LRUMap are changed.
13-
@Suppress("ConstPropertyName")
1413
private const val serialVersionUID = 4L
1514
}
1615

src/main/kotlin/io/github/projectmapk/jackson/module/kogera/deser/singletonSupport/KotlinBeanDeserializerModifier.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ internal class KotlinBeanDeserializerModifier(
1515
Serializable {
1616
companion object {
1717
// Increment is required when properties that use LRUMap are changed.
18-
@Suppress("ConstPropertyName")
1918
private const val serialVersionUID = 1L
2019
}
2120

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.projectmapk.jackson.module.kogera.zPorted.test.github;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
public class GitHub922RequiredCollectionsDtoJava {
10+
private final List<String> list;
11+
private final Map<String, String> map;
12+
13+
@JsonCreator
14+
public GitHub922RequiredCollectionsDtoJava(
15+
@JsonProperty(value = "list", required = true) List<String> list,
16+
@JsonProperty(value = "map", required = true) Map<String, String> map
17+
) {
18+
this.list = list;
19+
this.map = map;
20+
}
21+
22+
public List<String> getList() {
23+
return list;
24+
}
25+
26+
public Map<String, String> getMap() {
27+
return map;
28+
}
29+
}

src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/KotlinFeatures.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private class TestM11Changes {
195195
try {
196196
person.phone
197197
fail("While person can be deserialized without a phone, phone must be set before attempting to access it")
198-
} catch (e: IllegalStateException) { // expected
198+
} catch (_: IllegalStateException) { // expected
199199
}
200200
}
201201

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package io.github.projectmapk.jackson.module.kogera.zPorted.test.github
2+
3+
import com.fasterxml.jackson.databind.BeanDescription
4+
import com.fasterxml.jackson.databind.ObjectMapper
5+
import io.github.projectmapk.jackson.module.kogera.KotlinFeature
6+
import io.github.projectmapk.jackson.module.kogera.jacksonObjectMapper
7+
import org.junit.jupiter.api.Assertions.assertTrue
8+
import org.junit.jupiter.api.Test
9+
10+
class GitHub922 {
11+
private inline fun <reified T : Any> ObjectMapper.introspectSerialization(): BeanDescription =
12+
serializationConfig.introspect(serializationConfig.constructType(T::class.java))
13+
14+
private inline fun <reified T : Any> ObjectMapper.introspectDeserialization(): BeanDescription =
15+
deserializationConfig.introspect(deserializationConfig.constructType(T::class.java))
16+
17+
private fun BeanDescription.isRequired(propertyName: String): Boolean =
18+
this.findProperties().first { it.name == propertyName }.isRequired
19+
20+
@Test
21+
fun `nullToEmpty does not override specification by Java annotation`() {
22+
val mapper = jacksonObjectMapper {
23+
enable(KotlinFeature.NullToEmptyCollection)
24+
enable(KotlinFeature.NullToEmptyMap)
25+
}
26+
27+
val desc = mapper.introspectDeserialization<GitHub922RequiredCollectionsDtoJava>()
28+
29+
assertTrue(desc.isRequired("list"))
30+
assertTrue(desc.isRequired("map"))
31+
}
32+
}

src/test/kotlin/io/github/projectmapk/jackson/module/kogera/zPorted/test/github/Github161.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TestGithub161 {
2020
try {
2121
objectMapper.readValue(json, Foo::class.java)
2222
fail("Expected an error on the missing primitive value")
23-
} catch (ex: MismatchedInputException) {
23+
} catch (_: MismatchedInputException) {
2424
// success
2525
}
2626
}

0 commit comments

Comments
 (0)