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

Android Record Module doc updates #230

Merged
merged 1 commit into from
Nov 15, 2023
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
22 changes: 17 additions & 5 deletions android-record/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
Module that allows deserialization into records on Android,
where java records are supported through desugaring,
and Jackson's built-in support for records doesn't work,
since the desugared classes have a non-standard super class,
Module that allows (de)serialization of records using the canonical constructor and accessors on Android,
where java records are supported through desugaring, and Jackson's built-in support for records doesn't work,
since the desugared classes have a non-standard super class,
and record component-related reflection methods are missing.

See [Android Developers Blog article](https://android-developers.googleblog.com/2023/06/records-in-android-studio-flamingo.html)

Note: this module is a no-op when no Android-desugared records are being deserialized,
An attempt was made to make this module as consistent with Jackson's built-in support for records as possible,
but gaps exist when using some of Jackson's advanced mapping features.

Note: this module is a no-op when no Android-desugared records are being (de)serialized,
so it is safe to use in code shared between Android and non-Android platforms.

Note: the canonical record constructor is identified through matching of parameter names and types with fields.
Therefore, this module doesn't allow a deserialized desugared record to have a custom constructor
with the same set of parameter names and types as the canonical one.
For the same reason, this module requires that desugared canonical record constructor parameter names
be stored in class files. Apparently, with Android SDK 34 tooling, that is the case by default.
If that ever changes, it may require an explicit setting in build files.

Known limitation: this module replaces the default `ClassIntrospector`,
so it cannot be used together with any other module that does the same.

## Usage

Functionality can be used by registering the module and then just deserializing things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@
* Android Developers Blog article</a>
*
* <p>
* An attempt was made to make this module as consistent with Jackson's built-in support for records as possible,
* but gaps exist when using some of Jackson's advanced mapping features.
*
* <p>
* Note: this module is a no-op when no Android-desugared records are being (de)serialized,
* so it is safe to use in code shared between Android and non-Android platforms.
*
* <p>
* Note: the canonical record constructor is found through matching of parameter names and types with fields.
* Note: the canonical record constructor is identified through matching of parameter names and types with fields.
* Therefore, this module doesn't allow a deserialized desugared record to have a custom constructor
* with the same set of parameter names and types as the canonical one.
* For the same reason, this module requires that desugared canonical record constructor parameter names
* be stored in class files. Apparently, with Android SDK 34 tooling, that is the case by default.
* If that ever changes, it may require an explicit setting in build files.
*
* @author Eran Leshem
**/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ private MultipleConstructors(List<Integer> l, int i) {
int i() {
return i;
}

List<String> l() {
return l;
}
}


Expand Down