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

Kotlin Extension Property support for BeanWrapper [SPR-17280] #21813

Open
spring-issuemaster opened this issue Sep 17, 2018 · 2 comments
Open

Kotlin Extension Property support for BeanWrapper [SPR-17280] #21813

spring-issuemaster opened this issue Sep 17, 2018 · 2 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 17, 2018

Benjamin Winterberg opened SPR-17280 and commented

It would be really helpful for my current project if BeanWrapper would support resolving Kotlin Extension Properties.

Please see the following example for demonstration purpose:

data class Person(val firstName: String, val lastName: String)

val Person.fullName: String
    get() = "$firstName $lastName"

...

val person = Person("Peter", "Parker")
val beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(subject)
assertEquals("Peter Parker", beanWrapper.getPropertyValue("fullName"))

Extension Properties are a great way to structure large domain models without cluttering classes with usecase specific domain logic. We currently migrate large parts of our Java domain models to Kotlin. Since we use BeanWrapper for a few major features of our application, we currently have to work around Kotlin extension properties by using reflection to access those properties in case beanWrapper.isReadableProperty yields false.

It would be really helpful if BeanWrapper would support this out of the box, e.g. by passing packages including Kotlin extensions as a second optional argument:

val beanWrapper = PropertyAccessorFactory.forBeanPropertyAccess(subject, extensionPackages)

No further details from SPR-17280

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 3, 2018

Sébastien Deleuze commented

Any chance you could contribute such feature via a pull request?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 24, 2018

Sébastien Deleuze commented

I am not sure this feature would be useful for a wide audience, but seeing the implementation would help to evaluate more accurately. Could you please provide the code of your current workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.