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

spring-projects-issues opened this issue Sep 17, 2018 · 3 comments
in: core


Copy link

@spring-projects-issues spring-projects-issues 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

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 3, 2018

Sébastien Deleuze commented

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

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues 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?

@spring-projects-issues spring-projects-issues added status: waiting-for-triage type: enhancement in: core and removed type: enhancement labels Jan 11, 2019
Copy link

@sdeleuze sdeleuze commented Jan 19, 2022

Closing this issue due to the lack of feedback.

@sdeleuze sdeleuze removed the status: waiting-for-triage label Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core
None yet

No branches or pull requests

2 participants