Replace javaClass with Kotlin ::class for consistency#2976
Open
Luna712 wants to merge 2 commits into
Open
Conversation
I was originally just going to replace it in CustomSite, but figured I would do it all for consistency. When retrieving the data from CustomSite they would both resolve to the same thing so is backwards compatible. However, `::class.simpleName` can return null if something really goes wrong so we do handle that a little different for PlayerSettings, and bail out rather than setting to an empty string for CustomSite just to ensure consistency with current behavior also.
Eventually this will be needed anyway as we migrate more to KMP in library and Compose Multiplatform for UI, which as I am building compose, I am avoiding JVM specific stuff also so if we later expand to other platforms besides Android and JVM Desktop we can more easily do that as well.
I used Jackson's JsonAlias and Kotlinx Serialization's JsonNames annotations for CustomSite to maintain backwards compatibility for deserialization but future serialization would use the new name, so `parentClassName` rather than `parentJavaClass`.
I also added some extra comments to SettingsPlayer as the code kinda confused me, like what `add("")` was for, while I figured it out fairly quickly, I figured it didn't hurt to add comments to make it more clear in the future.
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.
I was originally just going to replace it in CustomSite, but figured I would do it all for consistency. When retrieving the data from CustomSite they would both resolve to the same thing so is backwards compatible. However,
::class.simpleNamecan return null if something really goes wrong so we do handle that a little different for PlayerSettings, and bail out rather than setting to an empty string for CustomSite just to ensure consistency with current behavior also.Eventually this will be needed anyway as we migrate more to KMP in library and Compose Multiplatform for UI, which as I am building compose, I am avoiding JVM specific stuff also so if we later expand to other platforms besides Android and JVM Desktop we can more easily do that as well.
I used Jackson's JsonAlias and Kotlinx Serialization's JsonNames annotations for CustomSite to maintain backwards compatibility for deserialization but future serialization would use the new name, so
parentClassNamerather thanparentJavaClass.I also added some extra comments to SettingsPlayer as the code kinda confused me, like what
add("")was for, while I figured it out fairly quickly, I figured it didn't hurt to add comments to make it more clear in the future.