Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17280

Kotlin Extension Property support for BeanWrapper

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Waiting for Triage
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      true

      Description

      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)

        Attachments

          Activity

            People

            Assignee:
            sdeleuze Sébastien Deleuze
            Reporter:
            winterbe Benjamin Winterberg
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              3 years, 23 weeks, 6 days ago