我想使用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
答案 0 :(得分: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
}
答案 1 :(得分:0)
在您的代码中,泛型类型是多余的。您的伴随对象扩展了抽象Base类,这可以用于自我类型注释,如@ om-nom-nom shows