我正在尝试为我拥有的抽象案例类创建MappedCOlumnType
。
sealed abstract class Address(address: String)
implicit val addressToString = MappedColumnType.base[Address, String](
addr => addr.address,
addr => AddressUtil.address(addr)
)
但是我收到编译错误,说明:
value address is not a member of com.suredbits.core.protocol.Address
[error] Note: implicit value addressToString is not applicable here because it comes after the application point and it lacks an explicit result type
[error] {addr => addr.address } , { addr => AddressUtil.address(addr) }
当我明确地将address
声明为案例类中的字段时。我觉得这对我来说可能是一个非常愚蠢的错误。为什么我的地址字段不可见?
答案 0 :(得分:0)
示例中的address
对构造函数是私有的。要使用getter将其公开,请将val
添加到其前面,如下所示:
sealed abstract class Address(val address: String)
HTH。