feat: add HiveConverter for custom TypeAdapter field conversion - #313
Draft
Rexios80 wants to merge 4 commits into
Draft
feat: add HiveConverter for custom TypeAdapter field conversion#313Rexios80 wants to merge 4 commits into
Rexios80 wants to merge 4 commits into
Conversation
Add a JsonConverter-style API for transforming field values during TypeAdapter generation. Converters can be applied via field/class annotations, AdapterSpec.converters, or GenerateAdapters.converters, including generic converters with inferred type arguments. Co-authored-by: Rexios <rexios@rexios.dev>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #313 +/- ##
==========================================
- Coverage 93.40% 93.37% -0.04%
==========================================
Files 64 65 +1
Lines 2625 2626 +1
==========================================
Hits 2452 2452
- Misses 173 174 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Remove AdapterSpec.converters and field/class annotation support. App-local Hive serialization only needs one converter per type, so GenerateAdapters.converters is sufficient. Co-authored-by: Rexios <rexios@rexios.dev>
DateTime is already supported by Hive natively, so Uri is a clearer demonstration of when a converter is needed. Co-authored-by: Rexios <rexios@rexios.dev>
Keep the json_serializable-like user API, but drop annotation/revive edge cases and replace recursive type unification with a smaller exact + identity-generic matcher. Co-authored-by: Rexios <rexios@rexios.dev>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
json_serializable-style type converter API so third-party types can be handled without hardcoding them into the generator (see #286).User API
Converters are registered only via
GenerateAdapters.converters. Matching is by field type (including simple generic converters likeIListConverter<T>→IList<String>).Design notes
JsonConverter(fromHive/toHive)AdapterSpec.convertersTest plan
GenerateAdapters.convertersgenerationUriConverter