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

codegen-kotlin: Support Java serialization of module classes #721

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

translatenix
Copy link
Contributor

This PR is based on #714.

Motivation:

  • Java serialization makes as much sense for module classes as it does for regular classes.
  • Offer same Java serialization support as codegen-java.

Changes:

  • Move generation of appendProperty method and serialization code
    into new method generateCompanionRelatedCode.
  • Improve/fix generation of serialization code.

Result:
Java serialization is also supported for module classes.

…zable for abstract classes

Motivation:
Don't generate code that isn't useful.

Changes:
- Don't generate equals/hashCode/toString/copy methods for abstract classes.
- Don't make abstract classes serializable.

Result:
- Less code is generated.
- Fixes apple#713.

Note:
codegen-java does the same for stateless classes, but it also makes them non-instantiable.
codegen-kotlin generates stateless regular classes far less often than codegen-java.
- use `assertContains()` instead of `assertThat().contains()`
- remove redundant `trimIndent()` and `trimMargin()` calls
- rename `javaCode` to `kotlinCode`
Motivation:
- Java serialization makes as much sense for module classes as it does for regular classes.
- Offer same Java serialization support as codegen-java.

Changes:
- Move generation of `appendProperty` method and serialization code
  into new method `generateCompanionRelatedCode`.
- Improve/fix generation of serialization code.

Result:
Java serialization is also supported for module classes.
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.

1 participant