Using @BeanProperty only to generate setter

Can I use Scala @BeanProperty annotation to create only a setter?

+5
source share
1 answer

As far as I know @BeanProperty, getter is synthesized for fields valand setter, as well as for var. It is not possible to generate only setters, so you must explicitly write the setter and not use @BeanProperty:

private var status = ""

def setStatus(s: String) { 
  this.status = s 
}

Pay attention to the field modifier private. Without it, a status()Scala-line getter will still be generated . For some reason, it is also generated using private var, but it is closed.

+6
source

All Articles