Skip to content
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

feat: added serialization for kotlinx.datetime #373

Merged
merged 5 commits into from
Oct 28, 2022

Conversation

rkreienbuehl
Copy link
Contributor

added serialization for kotlinx.datetime Instant, LocalDate, LocalDateTime and LocalTime

Fixes #323

@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Base: 58.17% // Head: 58.43% // Increases project coverage by +0.26% 🎉

Coverage data is based on head (bf72b5f) compared to base (72a0d04).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #373      +/-   ##
============================================
+ Coverage     58.17%   58.43%   +0.26%     
- Complexity      752      753       +1     
============================================
  Files           135      135              
  Lines          5604     5640      +36     
  Branches        477      477              
============================================
+ Hits           3260     3296      +36     
- Misses         2132     2133       +1     
+ Partials        212      211       -1     
Impacted Files Coverage Δ
...ain/kotlin/org/litote/kmongo/jackson/BsonModule.kt 64.77% <100.00%> (+2.93%) ⬆️
...in/org/litote/kmongo/jackson/ExtendedJsonModule.kt 81.81% <100.00%> (+2.59%) ⬆️
...n/kotlin/org/litote/kmongo/jackson/JacksonCodec.kt 57.57% <100.00%> (+2.73%) ⬆️
...litote/kmongo/coroutine/CoroutineClientSessions.kt 50.00% <0.00%> (-25.00%) ⬇️
...org/bson/codecs/pojo/PropertyReflectionUtils2.java 83.78% <0.00%> (+2.70%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@zigzago zigzago left a comment

Choose a reason for hiding this comment

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

@@ -54,6 +54,10 @@
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-serialization-core-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-datetime-jvm</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

add an <optional>true</optional>

KTXInstant::class to KTXInstantSerializer,
KTXLocalDate::class to KTXLocalDateSerializer,
KTXLocalDateTime::class to KTXLocalDateTimeSerializer,
KTXLocalTime::class to KTXLocalTimeSerializer,
Copy link
Member

Choose a reason for hiding this comment

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

check if the class KTXInstant is in the classpath before adding them

serializersMap: Map<KClass<*>, KSerializer<*>> = mapOf(...) + 
try {
  Class.forName("kotlinx.datetime.Instant")
  mapOf(
        KTXInstant::class to KTXInstantSerializer,
        KTXLocalDate::class to KTXLocalDateSerializer,
        KTXLocalDateTime::class to KTXLocalDateTimeSerializer,
        KTXLocalTime::class to KTXLocalTimeSerializer
  )
}
catch(e:ClassNotFoundException) { emptyMap() }

@rkreienbuehl
Copy link
Contributor Author

Thanks for your response. I will implement this and update the pull request.

@rkreienbuehl
Copy link
Contributor Author

Sorry for the delay. I had much to do. At first I forgot to implement jackson serialization. I now added jackson serialization and added tests.

@zigzago
Copy link
Member

zigzago commented Oct 28, 2022

LGTM. Thank you !

@zigzago zigzago merged commit 29f56f4 into Litote:master Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support kotlinx.datetime values
2 participants