我有以下抽象类:
abstract class Accessor {
def get(rowkey:String): Option[M2mModel]
def insertNew(model: M2mModel): Option[M2mModel]
}
abstract class Model(active:Int) {
@BeanProperty
var ttl = None
}
我的实现类是:
object AccountModel {
val COL_USERNAME = "username"
val COL_EMAIL = "email"
val COL_PASSWORD = "password"
val COL_DOMAIN = "domain"
val COL_ACTIVE = "active"
val COL_ROLE = "role"
val COL_ACLID = "aclid"
val definedFields = List(COL_USERNAME, COL_EMAIL, COL_PASSWORD, COL_DOMAIN,
COL_ACTIVE, COL_ROLE, COL_ACLID)
def apply(rowkey:String, email:String, password:String) = new AccountModel(rowkey, email, password)
}
case class AccountModel(rowkey: String, email:String, password: Option[String],
username: Option[String], domain: Option[String],
role: Option[String], active: Int, aclid: Option[String]) extends M2mModel(active) {
def this(rowkey:String, email:String, password:String) = this(rowkey, email, Some(password),
None, None, None, 1, None)
}
当我创建 Accessor 类并实现 insertNew 方法时,出现以下错误:无法创建对象,因为类型为 (model: package.Model)Option[package.Model] 的 Accessor 类中的方法 insertNew 未定义(请注意 package.型号与 package.AccountModel 不匹配)
这是我的实现类
object AccountAccess extends Accessor {
def insertNew(model: AccountModel): Option[AccountModel] = {
...do stuff
}
我究竟做错了什么?
谢谢