Lift:如何使这些关系具有多态性?
我有一个条目 它应该与三个“列表”之一相关,称它们为 ListA ListB ListC 我不知道如何使用 LongMappedMapper 来做到这一点。 那么我该怎么做呢?
我想让列表有多个条目,而不必为每种列表指定 listX 关系。 所以不:
class Entry ...{
object listA extends LongMappedMapper(this,ListA)
object listB extends LongMappedMapper(this,ListB)
...
}
我想要这样的东西:
class Entry ...{
object list extends PolyLongMappedMapper(this,ListA,ListB,ListC)
//PolyLongMappedMapper i the example mapper what i want
...
}
或者:
class Entry ...{
object list extends PolyLongMappedMapper(this,BaseListTrait)
//where BaseListTrait is a Trait shared by all List classes
//PolyLongMappedMapper i the example mapper what i want
...
}
Lift框架中的某些东西是我想要的吗?什么可以与 PolyLongMappedMapper 相媲美? 或者有一个优雅的方法来解决这个问题吗?
I got a Entry
it should be related to one of three "Lists" call them ListA ListB ListC
i couldnt figure out how to do this with LongMappedMapper.
So how could i do this?
I wanted to let the List have multiple entries without having to specify a listX relation for each kind of list.
So not:
class Entry ...{
object listA extends LongMappedMapper(this,ListA)
object listB extends LongMappedMapper(this,ListB)
...
}
I want something like:
class Entry ...{
object list extends PolyLongMappedMapper(this,ListA,ListB,ListC)
//PolyLongMappedMapper i the example mapper what i want
...
}
or:
class Entry ...{
object list extends PolyLongMappedMapper(this,BaseListTrait)
//where BaseListTrait is a Trait shared by all List classes
//PolyLongMappedMapper i the example mapper what i want
...
}
Is somewere something in the Lift framework what does what i want? what is comparable to the PolyLongMappedMapper?
Or is there an elegant way to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过以下方式执行此操作:
您的列表是:
时间:
Etam。
You can do this in such a way:
And your lista are:
when:
Etam.
它并不完美,但我创建了一个解决方法。
我找不到一种很好的方法来实现两个方向的多态性。
那么我们就从角色开始吧。角色在内部拥有角色玩家的权利,即。用户或进程或其他什么。
角色扮演者在应用程序中扮演角色。适用的是系统中的文件或文件夹或其他东西。
applialbe 有很多作用。角色扮演者有很多角色。由于不必为每个 appliable 定义关系,而只需使用 Appliable 特征进行扩展,我在 Role 类中创建了带有 appliableId 和 appliableClass 的 Workarout。
这是适用的即。文件夹或博客条目。
这里用 FunSuite 进行一个简短的测试:
Its not perfect but i created a workaround.
I couldnt find a way to do the polymorphism in both directions in a nice way.
So lets start with the role. the Role holds internally the Rights of a RolePlayer ie. a User or a process or whatever.
The Roleplayer plays a Role in a Appliable. The appliable is a File or a folder or something else in the system.
the applialbe has many roles. a roleplayer has many roles. for not having to define for each appliable the relation and just having to extend with the trait Appliable i created the Workarout wit appliableId and appliableClass in the Role class.
This is the Appliable ie. a Folder or a Blog entry.
And here a short test with FunSuite: