forked from FasterXML/jackson-module-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/com/fasterxml/jackson/module/kotlin/InternalCommons.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.fasterxml.jackson.module.kotlin | ||
|
||
import com.fasterxml.jackson.databind.JsonMappingException | ||
import java.util.* | ||
import kotlin.reflect.KType | ||
import kotlin.reflect.jvm.jvmErasure | ||
|
||
internal fun JsonMappingException.wrapWithPath(refFrom: Any?, refFieldName: String) = JsonMappingException.wrapWithPath(this, refFrom, refFieldName) | ||
internal fun JsonMappingException.wrapWithPath(refFrom: Any?, index: Int) = JsonMappingException.wrapWithPath(this, refFrom, index) | ||
|
||
internal fun Int.toBitSet(): BitSet { | ||
var i = this | ||
var index = 0 | ||
val bits = BitSet(32) | ||
while (i != 0) { | ||
if (i % 2 != 0) { | ||
bits.set(index) | ||
} | ||
++index | ||
i = i shr 1 | ||
} | ||
return bits | ||
} | ||
|
||
// In the future, value classes without @JvmInline will be available, and unboxing may not be able to handle it. | ||
// https://github.com/FasterXML/jackson-module-kotlin/issues/464 | ||
// The JvmInline annotation can be added to Java classes, | ||
// so the isKotlinClass decision is necessary (the order is preferable in terms of possible frequency). | ||
internal fun Class<*>.isUnboxableValueClass() = annotations.any { it is JvmInline } && this.isKotlinClass() | ||
|
||
internal fun KType.erasedType(): Class<out Any> = this.jvmErasure.java |
This file was deleted.
Oops, something went wrong.