Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of @BeanProperty for setter generation only

Tags:

scala

Is it possible to use the Scala @BeanProperty annotation to create only the setter?

like image 594
Timo Westkämper Avatar asked Jan 21 '12 11:01

Timo Westkämper


1 Answers

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

private var status = ""

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

Note the private field modifier. Without it the status() Scala-style getter will still be generated. For some reason it is generated as well with private var, but it's private.

like image 54
Tomasz Nurkiewicz Avatar answered Sep 27 '22 19:09

Tomasz Nurkiewicz