https://github.com/zacsweers/entitydataclassfrommodules
Demo project for https://issuetracker.google.com/issues/67181813
https://github.com/zacsweers/entitydataclassfrommodules
Last synced: 4 days ago
JSON representation
Demo project for https://issuetracker.google.com/issues/67181813
- Host: GitHub
- URL: https://github.com/zacsweers/entitydataclassfrommodules
- Owner: ZacSweers
- Created: 2017-10-01T03:16:13.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-01T03:17:45.000Z (about 8 years ago)
- Last Synced: 2025-09-23T14:54:19.457Z (16 days ago)
- Language: Kotlin
- Homepage:
- Size: 170 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Details:
Important classes are `SampleDB.kt` and `SampleEntity.kt`.
In `SampleDB.kt` you'll find the room db scaffolding along with a `SampleEntity` data class implementation commented out. Call this condition `A`
In `SampleEntity.kt`, there are two different implementations of the `SampleEntity` data class.
One is a standard data class with `val` properties and no extra constructors, it is also commented out. Call this condition `B`.
The other is the same data class but with `var` properties and extra constructors for non-defaulting properties. Call this condition `C`.
The issue is that only `C` works if being consumed from an external module. This is unfortunate because `C` is not a very ideal data class with is mutable properties and boilerplate constructors (they aren't actually used at runtime in my experience).
If you use `B` (with the others commented out), it will fail because it can't find setters for the `val` variables nor an appropriate constructor for it.
If you use `A` (with the others commented out), it will work because it's in the same module.
Ideal case is that `B` should work, as it's the conventional way data classes are written in Kotlin and does work if it's from the same module.