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

Support java record #27

Merged
merged 1 commit into from
Mar 8, 2021
Merged

Support java record #27

merged 1 commit into from
Mar 8, 2021

Conversation

zhxnlai
Copy link
Collaborator

@zhxnlai zhxnlai commented Jan 23, 2021

@zhxnlai zhxnlai requested a review from swankjesse January 23, 2021 19:00
@zhxnlai zhxnlai force-pushed the zl-210123-support-java-record branch from 3e67cc4 to 96fc15e Compare January 23, 2021 19:47
fun getApp(value: A) = appProperty.get(value)
fun getApp(value: A): P {
if (!appProperty.isAccessible) {
appProperty.javaField!!.trySetAccessible()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to set these as accessible when you init the appProperty field?

@@ -95,7 +94,11 @@ internal class ReflectionCodec<A : Any, D : Any> private constructor(
.map { it.parameter to it.getDb(dbItem) }
.toMap()
val appItem =
appItemConstructor?.callBy(constructorArgs) ?: appItemClassFactory.newInstance()
if (appItemConstructor != null && constructorArgs.size == appItemConstructor.parameters.size) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanna add an explicit check to see if it’s a record? rather than relying on constructor parameter count equaling field count?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky because this gradle module compiles against Java 11 which doesn't have the Record base class

@zhxnlai zhxnlai merged commit d5880ce into master Mar 8, 2021
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.

2 participants