com.evolveum.midpoint.prism.Item.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(111)

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

Item.getParent介绍

[英]Returns the parent of this item (if exists). Currently this has to be a PrismContainerValue.
[中]返回此项的父项(如果存在)。目前,这必须是一个PrismContainerValue。

代码示例

代码示例来源:origin: Evolveum/midpoint

public static PrismContainerValue<?> getParentContainerValue(PrismValue value) {
  Itemable parent = value.getParent();
  if (parent instanceof Item) {
    PrismValue parentParent = ((Item) parent).getParent();
    return parentParent instanceof PrismContainerValue ? (PrismContainerValue) parentParent : null;
  } else {
    return null;
  }
}

代码示例来源:origin: Evolveum/midpoint

@Override
public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) {
  ItemPath myPath = getPath();
  if (getDefinition() == null) {
    throw new IllegalStateException("Definition-less container value " + this +" ("+myPath+" in "+rootItem+")");
  }
  if (items != null) {
    for (Item<?,?> item: items) {
      if (scope.isThorough()) {
        if (item == null) {
          throw new IllegalStateException("Null item in container value "+this+" ("+myPath+" in "+rootItem+")");
        }
        if (item.getParent() == null) {
          throw new IllegalStateException("No parent for item "+item+" in container value "+this+" ("+myPath+" in "+rootItem+")");
        }
        if (item.getParent() != this) {
          throw new IllegalStateException("Wrong parent for item "+item+" in container value "+this+" ("+myPath+" in "+rootItem+"), " +
              "bad parent: "+ item.getParent());
        }
      }
      item.checkConsistenceInternal(rootItem, requireDefinitions, prohibitRaw, scope);
    }
  }
}

代码示例来源:origin: Evolveum/midpoint

public static void assertParentConsistency(PrismContainerValue<?> pval) {
  if (pval.getItems() != null) {
    for (Item<?,?> item : pval.getItems()) {
      assert item.getParent() == pval : "Wrong parent in " + item;
      assertParentConsistency(item);
    }
  }
}

代码示例来源:origin: Evolveum/midpoint

public void removeOperationalItems() {
    accept(visitable -> {
      if (visitable instanceof Item) {
        Item item = ((Item) visitable);
        if (item.getDefinition() != null && item.getDefinition().isOperational()) {
          PrismValue parent = item.getParent();
          if (parent instanceof PrismContainerValue) {    // should be the case
            ((PrismContainerValue) parent).remove(item);
          }
        }
      }
    });
  }
}

代码示例来源:origin: Evolveum/midpoint

private void cleanupAllTheWayUp(Item<?,?> item) {
  if (item.isEmpty()) {
    PrismValue itemParent = item.getParent();
    if (itemParent != null) {
      ((PrismContainerValue<?>)itemParent).remove(item);
      if (itemParent.isEmpty()) {
        Itemable itemGrandparent = itemParent.getParent();
        if (itemGrandparent != null) {
          if (itemGrandparent instanceof Item<?,?>) {
            cleanupAllTheWayUp((Item<?,?>)itemGrandparent);
          }
        }
      }
    }
  }
}

相关文章