org.apache.brooklyn.core.entity.Entities.isDescendant()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.2k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.apache.brooklyn.core.entity.Entities.isDescendant()方法的一些代码示例,展示了Entities.isDescendant()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entities.isDescendant()方法的具体详情如下:
包路径:org.apache.brooklyn.core.entity.Entities
类名称:Entities
方法名:isDescendant

Entities.isDescendant介绍

[英]Checks whether the descendants of the given ancestor contains the given potentialDescendant.

In this test, unlike in #descendants(Entity), an entity is not counted as a descendant. note, it is usually preferred to use isAncestor() and swap the order, it is a cheaper method.
[中]检查给定祖先的后代是否包含给定的潜在后代。
在本测试中,与In#substands(实体)不同,实体不算作子体。注意,通常最好使用isAncestor()并交换订单,这是一种更便宜的方法。

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Test
  public void testIsDescendant() {
    Entity e = app.addChild(EntitySpec.create(TestEntity.class));
    Entity e2 = e.addChild(EntitySpec.create(TestEntity.class));

    assertTrue(Entities.isDescendant(app, e));
    assertTrue(Entities.isDescendant(app, e2));
    assertFalse(Entities.isDescendant(e2, e));
    assertFalse(Entities.isDescendant(e2, e2));
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

if (Entities.isDescendant(this, entity))
  throw new IllegalStateException("loop detected trying to set parent of "+this+" as "+entity+", which is already a descendent");

相关文章