I have been looking at some Scala code written by someone else a while ago. Some of that codebase needs cleanup. For example, I don’t see any case classes in this codebase.
So, here is an shortened representation of a class from that codebase. Its looks like the code below:
class X (@BeanProperty val dc: DoubleContainer, private val _ps: List[DoubleContainer],
@BeanProperty val aS: Double, @BeanProperty val bS: Double) {
private val _d1: Container1[DoubleContainer] = (p1: DoubleContainer, p2: DoubleContainer) =>
functionReturningDouble(p1, p2) * aS
private val _d2: Container1[DoubleContainer] = (p1: DoubleContainer, p2: DoubleContainer) =>
functionReturningDouble(p1, p2) * bS
def this(dc: DoubleContainer, dcs: List[DoubleContainer], b: Double) = this(dc, dcs, 1, b)
def this(i: Container2, a: Double, b: Double) =
this(i.dc, i._ps, a, b)
}
The DoubleContainer and Container2 are classes that don’t need to be represented here.
Class X resembles a Javabean somewhat and doesn’t look very nice. I don’t see any reason why those @BeanProperty annotations should be present. I am not sure what it is doing here.,
Can this be rewritten as a case class without all those ‘this’ constructors?
Perhaps I need to create apply() methods?
Thanks,.