O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Following the JavaBean Convention

The accessors that the Scala compiler generates by default don’t conform to the JavaBean method naming conversion. This is not a big deal if your classes are used only from Scala. But, it’s rather undesirable if the classes are used from Java. That’s because, since both Java programmers and Java IDEs are so used to the JavaBean convention, the Scala style accessors would be confusing and hard to use from Java. Furthermore, most Java frameworks assume the JavaBean convention and not following that would make it hard to use Scala classes with those frameworks. No sweat—it’s an easy fix with an annotation.

Simply mark the desired field declarations with the scala.beans.BeanProperty annotation. Upon seeing this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required