@Override public void trimTo(@NotNull Collection<ItemPath> paths) { if (shared) { // TODO switch this to warning before releasing this code (3.6.1 or 3.7) throw new IllegalStateException("Couldn't trim shared definition: " + this); } for (Iterator<ItemDefinition> iterator = itemDefinitions.iterator(); iterator.hasNext(); ) { ItemDefinition<?> itemDef = iterator.next(); ItemPath itemPath = itemDef.getName(); if (!ItemPathCollectionsUtil.containsSuperpathOrEquivalent(paths, itemPath)) { iterator.remove(); } else if (itemDef instanceof PrismContainerDefinition) { PrismContainerDefinition<?> itemPcd = (PrismContainerDefinition<?>) itemDef; if (itemPcd.getComplexTypeDefinition() != null) { itemPcd.getComplexTypeDefinition().trimTo(ItemPathCollectionsUtil.remainder(paths, itemPath, false)); } } } }
void trimItemsDefinitionsTrees(Collection<? extends ItemPath> alwaysKeep) { // to play safe, we won't touch PCV-specific complexTypeDefinition for (Item<?, ?> item : CollectionUtils.emptyIfNull(items)) { if (item instanceof PrismContainer) { Collection<ItemPath> alwaysKeepInSub = ItemPathCollectionsUtil.remainder(CollectionUtils.emptyIfNull(alwaysKeep), item.getElementName(), false); ((PrismContainer<?>) item).trimDefinitionTree(alwaysKeepInSub); } } }