static <T extends Item> Collection<T> cloneCollection(Collection<T> items) { Collection<T> clones = new ArrayList<>(items.size()); for (T item: items) { clones.add((T)item.clone()); } return clones; }
protected void copyValues(ItemDeltaItem<V,D> clone) { if (this.itemNew != null) { clone.itemNew = this.itemNew.clone(); } if (this.delta != null) { clone.delta = this.delta.clone(); } if (this.itemOld != null) { clone.itemOld = this.itemOld.clone(); } clone.residualPath = this.residualPath; clone.resolvePath = this.resolvePath; if (this.subItemDeltas != null) { clone.subItemDeltas = ItemDeltaCollectionsUtil.cloneCollection(this.subItemDeltas); } }
public Item<V,D> getItemNewMatchingPath(Item<V,D> itemOld) throws SchemaException { if (definition == null) { throw new IllegalStateException("No definition in "+this); } Item<V,D> itemNew; if (itemOld == null) { if (isEmpty()) { return null; } itemNew = definition.instantiate(getElementName()); } else { itemNew = itemOld.clone(); } applyToMatchingPath(itemNew, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); return itemNew; }
@SuppressWarnings("unchecked") public void mergeContent(PrismContainerValue<?> other, List<QName> overwrite) throws SchemaException { List<ItemName> remainingToOverwrite = overwrite.stream().map(ItemName::fromQName).collect(Collectors.toList()); if (other.getItems() != null) { for (Item<?, ?> otherItem : other.getItems()) { Item<?, ?> existingItem = findItem(otherItem.getElementName()); if (QNameUtil.remove(remainingToOverwrite, otherItem.getElementName()) || existingItem != null && existingItem.isSingleValue()) { remove(existingItem); } merge(otherItem.clone()); } } remainingToOverwrite.forEach(name -> removeItem(name, Item.class)); }
/** * Returns the "new" state of the property - the state that would be after * the delta is applied. */ public Item<V,D> getItemNew(Item<V,D> itemOld) throws SchemaException { if (definition == null) { throw new IllegalStateException("No definition in "+this); } Item<V,D> itemNew; if (itemOld == null) { if (isEmpty()) { return null; } itemNew = definition.instantiate(getElementName()); } else { itemNew = itemOld.clone(); } applyTo(itemNew); return itemNew; }
if (containerCVal != null) { for (Item<?,?> containerItem: containerCVal.getItems()) { deltaCVal.add(containerItem.clone());
private boolean hasValue(Item<V,D> item, ItemDelta<V,D> itemDelta) throws SchemaException { if (item == null || item.isEmpty()) { return itemDelta != null && itemDelta.addsAnyValue(); } else { if (itemDelta == null || itemDelta.isEmpty()) { return true; } else { Item<V,D> clonedItem = item.clone(); itemDelta.applyToMatchingPath(clonedItem, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); return !clonedItem.isEmpty(); } } }
public static void mergeExtension(PrismContainerValue<?> dstExtensionContainerValue, PrismContainerValue<?> srcExtensionContainerValue) throws SchemaException { for (Item<?,?> srcExtensionItem: emptyIfNull(srcExtensionContainerValue.getItems())) { Item<?,?> magicItem = dstExtensionContainerValue.findItem(srcExtensionItem.getElementName()); if (magicItem == null) { //noinspection unchecked dstExtensionContainerValue.add(srcExtensionItem.clone()); } } }
private static void convertToLegacy( ItemDeltaItem<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> idi) { if (idi == null || idi.getDelta() == null || idi.getSubItemDeltas() != null) { return; } // Legacy approach (when adding/removing assignments) was: itemOld+itemNew = value, delta = null // This was recently changed, to provide precise information (add = null->itemNew, delete = itemOld->null). // However, to not break scripts before 3.6 release we provide imitation of old behavior here. // (Moreover, for magic assignment the delta is not correct anyway.) if (idi.getDelta().isAdd() || idi.getDelta().isReplace()) { idi.setItemOld(idi.getItemNew().clone()); } else { idi.setItemNew(idi.getItemOld().clone()); } idi.setDelta(null); }
return (T) ((Item<?,?>)orig).clone();
newTask.setExecutionStatus(RUNNABLE); for (Item<?, ?> extensionItem : extensionItems) { newTask.asPrismObject().getExtension().add(extensionItem.clone());
definitionForReport.getValue().add(item.clone());
Item item = (Item) value; if (!item.isImmutable()) { Item clone = item.clone(); clone.setImmutable(true); return (T) clone;