有没有可能向我的自定义服务传递一个对象列表( PhysicalComponent )来阻止我遍历所有的PhysicalComponent?
实际上,我在我的M2DOC模板中像这样迭代:
{m:for pc | self.eAllContents(pa::PhysicalComponent)}
{m:pc.MatrixFlow()}
{m:endfor}发布于 2019-12-03 17:26:02
您可以使用以下签名创建服务:
public SomeReturnType myService(List<PhysicalComponent> components) {
...
}或
public SomeReturnType myService(Set<PhysicalComponent> components) {
...
}或
public SomeReturnType myService(Collection<PhysicalComponent> components) {
...
}然后你可以这样调用它,例如:
{m:self.eAllContents(pa::PhysicalComponent)->myService()}箭头告诉将集合传递给服务,点告诉在集合的每个元素上调用服务。
如果使用集合列表作为第一个参数,则可能需要使用asSequence()或asOrderedSet():
{m:self.eAllContents(pa::PhysicalComponent)->asSequence()->myService()}或
{m:self.eAllContents(pa::PhysicalComponent)->asOrderedSet()->myService()}https://stackoverflow.com/questions/59153673
复制相似问题