Skip to content

Renamed "com.fasterxml.jackson" -> "tools.jackson" #598 #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.13.+"
Maven:
```xml
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<groupId>tools.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<version>2.13.4</version>
</dependency>
Expand All @@ -40,16 +40,16 @@ To use, just register the Kotlin module with your ObjectMapper instance:

```kotlin
// With Jackson 2.12 and later
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import tools.jackson.module.kotlin.jacksonObjectMapper
...
val mapper = jacksonObjectMapper()
// or
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import tools.jackson.module.kotlin.registerKotlinModule
...
val mapper = ObjectMapper().registerKotlinModule()
// or
import com.fasterxml.jackson.module.kotlin.jsonMapper
import com.fasterxml.jackson.module.kotlin.kotlinModule
import tools.jackson.module.kotlin.jsonMapper
import tools.jackson.module.kotlin.kotlinModule
...
val mapper = jsonMapper {
addModule(kotlinModule())
Expand All @@ -61,7 +61,7 @@ val mapper = jsonMapper {

```kotlin
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import tools.jackson.module.kotlin.KotlinModule
...
val mapper = JsonMapper.builder().addModule(KotlinModule()).build()
```
Expand All @@ -73,16 +73,16 @@ val mapper = JsonMapper.builder().addModule(KotlinModule()).build()

```kotlin
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.KotlinModule
import tools.jackson.module.kotlin.KotlinModule
...
val mapper = ObjectMapper().registerModule(KotlinModule())
```
</details>

A simple data class example:
```kotlin
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import tools.jackson.module.kotlin.jacksonObjectMapper
import tools.jackson.module.kotlin.readValue

data class MyStateObject(val name: String, val age: Int)

Expand All @@ -104,7 +104,7 @@ Also, there are some convenient operator overloading extension functions for Jso
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.module.kotlin.*
import tools.jackson.module.kotlin.*

// ...
val objectNode: ObjectNode = JsonNodeFactory.instance.objectNode()
Expand Down
44 changes: 24 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<id>viartemev</id>
<name>Vyacheslav Artemyev</name>
</developer>
<developer>
<id>realyusufismail</id>
<name>Yusuf Arfan Ismail</name>
</developer>
</developers>
<url>https://github.com/FasterXML/jackson-module-kotlin</url>
<scm>
Expand All @@ -55,7 +59,7 @@
<version.kotlin>1.6.21</version.kotlin>

<!-- Generate PackageVersion.java into this directory. -->
<packageVersion.dir>com/fasterxml/jackson/module/kotlin</packageVersion.dir>
<packageVersion.dir>tools/jackson/module/kotlin</packageVersion.dir>
<packageVersion.package>${project.groupId}.kotlin</packageVersion.package>

<!-- Configuration properties for the OSGi maven-bundle-plugin -->
Expand Down Expand Up @@ -214,22 +218,22 @@
</plugins>
</build>

<!-- Alas, need to include snapshot reference since otherwise can not find
snapshot of parent... -->
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>sonatype-old-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots (old)</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</project>
<!-- Alas, need to include snapshot reference since otherwise can not find
snapshot of parent... -->
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>sonatype-old-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots (old)</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import kotlin.reflect.KFunction
import kotlin.reflect.jvm.isAccessible

internal class ConstructorValueCreator<T>(override val callable: KFunction<T>) : ValueCreator<T>() {
internal class ConstructorValueCreator<T>(override val callable: KFunction<T>) : tools.jackson.module.kotlin.ValueCreator<T>() {
override val accessible: Boolean = callable.isAccessible

init {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.JsonParser
import tools.jackson.databind.exc.MismatchedInputException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.JsonParser
import tools.jackson.core.TreeNode
Expand Down Expand Up @@ -35,7 +35,10 @@ fun jsonMapper(initializer: JsonMapper.Builder.() -> Unit = {}): JsonMapper {
return builder.build()
}

fun jacksonObjectMapper(): ObjectMapper = jsonMapper { addModule(kotlinModule()) }
//TODO: causing java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
fun jacksonObjectMapper(): ObjectMapper =
jsonMapper { addModule(kotlinModule()) }

fun jacksonMapperBuilder(): JsonMapper.Builder = JsonMapper.builder().addModule(kotlinModule())

// 22-Jul-2019, tatu: Can not be implemented same way as in 2.x, addition via mapper.builder():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
Expand Down Expand Up @@ -204,7 +204,7 @@ internal class KotlinAnnotationIntrospector(private val context: JacksonModule.S
}

private fun KFunction<*>.isMethodParameterRequired(index: Int): Boolean {
return isParameterRequired(index+1)
return isParameterRequired(index + 1)
}

private fun KFunction<*>.isParameterRequired(index: Int): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.JsonParser
import tools.jackson.core.JsonToken.VALUE_NUMBER_INT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import java.util.BitSet
import kotlin.math.pow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.JsonToken
import tools.jackson.core.exc.InputCoercionException
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import com.fasterxml.jackson.annotation.JsonFormat
import tools.jackson.core.JsonGenerator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.json.PackageVersion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong! This is not the version to use here, MUST be Kotlin module's own version def.
(will fix post-merge)

import tools.jackson.databind.MapperFeature
import tools.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
import com.fasterxml.jackson.module.kotlin.SingletonSupport.CANONICALIZE
import com.fasterxml.jackson.module.kotlin.SingletonSupport.DISABLED
import tools.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
import tools.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
import tools.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
import tools.jackson.module.kotlin.KotlinFeature.StrictNullChecks
import tools.jackson.module.kotlin.SingletonSupport.CANONICALIZE
import tools.jackson.module.kotlin.SingletonSupport.DISABLED
import java.util.*
import kotlin.reflect.KClass

Expand All @@ -26,7 +27,7 @@ fun Class<*>.isKotlinClass(): Boolean {
* @param nullIsSameAsDefault Default false. Whether to treat null values as absent when deserializing, thereby
* using the default value provided in Kotlin.
* @param singletonSupport Default: DISABLED. Mode for singleton handling.
* See {@link com.fasterxml.jackson.module.kotlin.SingletonSupport label}
* See {@link tools.jackson.module.kotlin.SingletonSupport label}
* @param strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
* the default, collections which are typed to disallow null members
* (e.g. List<String>) may contain null values after deserialization. Enabling it
Expand All @@ -44,7 +45,7 @@ class KotlinModule @Deprecated(
.configure(KotlinFeature.SingletonSupport, singletonSupport)
.configure(KotlinFeature.StrictNullChecks, strictNullChecks)
.build()""",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
) constructor(
val reflectionCacheSize: Int = 512,
Expand Down Expand Up @@ -176,7 +177,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use isEnabled(NullToEmptyCollection) instead.",
replaceWith = ReplaceWith(
"isEnabled(KotlinFeature.NullToEmptyCollection)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun getNullToEmptyCollection(): Boolean =
Expand All @@ -186,7 +187,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use configure(NullToEmptyCollection, enabled) instead.",
replaceWith = ReplaceWith(
"configure(KotlinFeature.NullToEmptyCollection, nullToEmptyCollection)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun nullToEmptyCollection(nullToEmptyCollection: Boolean): Builder =
Expand All @@ -196,7 +197,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use isEnabled(NullToEmptyMap) instead.",
replaceWith = ReplaceWith(
"isEnabled(KotlinFeature.NullToEmptyMap)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun getNullToEmptyMap(): Boolean =
Expand All @@ -206,7 +207,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use configure(NullToEmptyMap, enabled) instead.",
replaceWith = ReplaceWith(
"configure(KotlinFeature.NullToEmptyMap, nullToEmptyMap)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun nullToEmptyMap(nullToEmptyMap: Boolean): Builder =
Expand All @@ -216,7 +217,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use isEnabled(NullIsSameAsDefault) instead.",
replaceWith = ReplaceWith(
"isEnabled(KotlinFeature.NullIsSameAsDefault)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun getNullIsSameAsDefault(): Boolean =
Expand All @@ -226,7 +227,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use configure(NullIsSameAsDefault, enabled) instead.",
replaceWith = ReplaceWith(
"configure(KotlinFeature.NullIsSameAsDefault, nullIsSameAsDefault)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun nullIsSameAsDefault(nullIsSameAsDefault: Boolean): Builder =
Expand All @@ -236,7 +237,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use isEnabled(SingletonSupport) instead.",
replaceWith = ReplaceWith(
"isEnabled(KotlinFeature.SingletonSupport)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun getSingletonSupport(): SingletonSupport =
Expand All @@ -249,7 +250,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use configure(SingletonSupport, enabled) instead.",
replaceWith = ReplaceWith(
"configure(KotlinFeature.SingletonSupport, singletonSupport)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun singletonSupport(singletonSupport: SingletonSupport): Builder =
Expand All @@ -262,7 +263,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use isEnabled(StrictNullChecks) instead.",
replaceWith = ReplaceWith(
"isEnabled(KotlinFeature.StrictNullChecks)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun getStrictNullChecks(): Boolean =
Expand All @@ -272,7 +273,7 @@ class KotlinModule @Deprecated(
message = "Deprecated, use configure(StrictNullChecks, enabled) instead.",
replaceWith = ReplaceWith(
"configure(KotlinFeature.StrictNullChecks, strictNullChecks)",
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
"tools.jackson.module.kotlin.KotlinFeature"
)
)
fun strictNullChecks(strictNullChecks: Boolean): Builder =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonCreator.Mode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.core.JsonParser
import tools.jackson.databind.BeanProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonValue
Expand All @@ -22,18 +22,21 @@ object SequenceSerializer : StdSerializer<Sequence<*>>(Sequence::class.java) {
}

object UByteSerializer : StdSerializer<UByte>(UByte::class.java) {
override fun serialize(value: UByte, gen: JsonGenerator, provider: SerializerProvider) =
override fun serialize(value: UByte, gen: JsonGenerator, provider: SerializerProvider) {
gen.writeNumber(value.toShort())
}
}

object UShortSerializer : StdSerializer<UShort>(UShort::class.java) {
override fun serialize(value: UShort, gen: JsonGenerator, provider: SerializerProvider) =
override fun serialize(value: UShort, gen: JsonGenerator, provider: SerializerProvider) {
gen.writeNumber(value.toInt())
}
}

object UIntSerializer : StdSerializer<UInt>(UInt::class.java) {
override fun serialize(value: UInt, gen: JsonGenerator, provider: SerializerProvider) =
override fun serialize(value: UInt, gen: JsonGenerator, provider: SerializerProvider) {
gen.writeNumber(value.toLong())
}
}

object ULongSerializer : StdSerializer<ULong>(ULong::class.java) {
Expand Down Expand Up @@ -151,4 +154,4 @@ internal class ValueClassStaticJsonValueSerializer<T> private constructor(
.getStaticJsonValueGetter()
?.let { ValueClassStaticJsonValueSerializer(innerClazz, it) }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.module.kotlin
package tools.jackson.module.kotlin

import tools.jackson.databind.BeanDescription
import tools.jackson.databind.DeserializationConfig
Expand Down
Loading