BeanProperty
scala.beans.BeanProperty
class BeanProperty extends StaticAnnotation
When attached to a field, this annotation adds a setter and a getter method following the Java Bean convention. For example:
class Person:
@BeanProperty
var status = ""
adds the following methods to the class:
class Person:
@BeanProperty
var status = ""
// The annotation generates:
// def setStatus(s: String): Unit = { this.status = s }
// def getStatus(): String = this.status
For fields of type Boolean, if you need a getter named isStatus, use the scala.beans.BooleanBeanProperty annotation instead.
In Scala 2, the added methods are visible from both Scala and Java.
In Scala 3, that has changed. The added methods are only visible from Java (including via Java reflection).
Attributes
- Source
- BeanProperty.scala
- Graph
-
- Supertypes
In this article