-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from ProjectMapK/develop
Release 2023-12-20 12:53:18 +0000
- Loading branch information
Showing
22 changed files
with
525 additions
and
176 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
47 changes: 47 additions & 0 deletions
47
src/main/java/io/github/projectmapk/jackson/module/kogera/deser/ValueClassDeserializer.java
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,47 @@ | ||
package io.github.projectmapk.jackson.module.kogera.deser; | ||
|
||
import com.fasterxml.jackson.databind.JavaType; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import io.github.projectmapk.jackson.module.kogera.deser.deserializers.ValueClassBoxDeserializer; | ||
import kotlin.jvm.JvmClassMappingKt; | ||
import kotlin.reflect.KClass; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* An interface to be inherited by JsonDeserializer that handles value classes that may wrap nullable. | ||
* @see ValueClassBoxDeserializer for implementation. | ||
*/ | ||
// To ensure maximum compatibility with StdDeserializer, this class is defined in Java. | ||
public abstract class ValueClassDeserializer<D> extends StdDeserializer<D> { | ||
protected ValueClassDeserializer(@NotNull KClass<?> vc) { | ||
super(JvmClassMappingKt.getJavaClass(vc)); | ||
} | ||
|
||
protected ValueClassDeserializer(@NotNull Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
protected ValueClassDeserializer(@NotNull JavaType valueType) { | ||
super(valueType); | ||
} | ||
|
||
protected ValueClassDeserializer(@NotNull StdDeserializer<D> src) { | ||
super(src); | ||
} | ||
|
||
@Override | ||
@NotNull | ||
public final Class<D> handledType() { | ||
//noinspection unchecked | ||
return (Class<D>) super.handledType(); | ||
} | ||
|
||
/** | ||
* If the parameter definition is a value class that wraps a nullable and is non-null, | ||
* and the input to JSON is explicitly null, this value is used. | ||
*/ | ||
// It is defined so that null can also be returned so that Nulls.SKIP can be applied. | ||
@Nullable | ||
public abstract D getBoxedNullValue(); | ||
} |
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
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
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
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
Oops, something went wrong.