0

我想使用 scala 将特征传递给抽象类,这就是我目前所拥有的:

trait User extends VertexFrame {}

trait Member extends VertexFrame {}

object Member extends Base[Member] {}

object User extends Base[User] {}

abstract class Base[T <: VertexFrame: Manifest] {
  // Here if want to be able to access my "trait User" or my "trait Member"
  def list = {
   graph.frameVertices(graph.getVertices, manifest[T].runtimeClass).toList
  }
}

图:http ://www.tinkerpop.com/docs/javadocs/frames/2.0.0/com/tinkerpop/frames/FramedGraph.html

4

2 回答 2

2

看看这是否是您正在寻找的(根据您的评论):

abstract class Base[T <: VertexFrame: Manifest] { self =>
  // Here if want to be able to access my "trait User" or my "trait Member"
  def test = manifest[T].runtimeClass
}
于 2013-05-28T15:46:25.367 回答
0

在您的代码中,泛型类型是多余的。您的伴侣对象扩展了抽象基类,这可以用于自我类型注释,如@om-nom-nom 所示

于 2013-05-28T13:11:21.777 回答