public static <X extends PrismValue> Collection<X> cloneValues(Collection<X> values) { Collection<X> clonedCollection = new ArrayList<>(values.size()); for (X val: values) { clonedCollection.add((X) val.clone()); } return clonedCollection; }
@Nullable List<V> getClonedValues() { if (values == null) { return null; } else { List<V> clonedValues = new ArrayList<>(values.size()); for (V value : values) { @SuppressWarnings("unchecked") V cloned = (V) value.clone(); clonedValues.add(cloned); } return clonedValues; } }
protected void copyValues(ItemValueWithOrigin<V,D> clone) { if (this.itemValue != null) { clone.itemValue = (V) this.itemValue.clone(); } if (this.mapping != null) { clone.mapping = this.mapping.clone(); } clone.construction = this.construction; }
@Nullable V getClonedValue() { V value = getSingleValue(); if (value == null) { return null; } else { @SuppressWarnings("unchecked") V cloned = (V) value.clone(); return cloned; } }
protected void copyValues(PrismValueDeltaSetTripleImpl<V> clone) { super.copyValues(clone, original -> (V) original.clone()); }
private Collection<PrismValue> diffValues(List<PrismValue> currentValues, Collection<PrismValue> valuesToLeave) { if (valuesToLeave == null || valuesToLeave.isEmpty()) { return PrismValueCollectionsUtil.cloneCollection(currentValues); } Collection<PrismValue> diff = new ArrayList<>(); for (PrismValue currentValue: currentValues) { if (!PrismValueCollectionsUtil.collectionContainsEquivalentValue(valuesToLeave, currentValue)) { diff.add(currentValue.clone()); } } return diff; }
public Collection<V> getClonedValues() { Collection<V> clonedValues = new ArrayList<>(getValues().size()); for (V val: getValues()) { clonedValues.add((V)val.clone()); } return clonedValues; }
private Collection<V> cloneSet(ItemDeltaImpl clone, Collection<V> thisSet) { if (thisSet == null) { return null; } Collection<V> clonedSet = newValueCollection(); for (V thisVal : thisSet) { V clonedVal = (V) thisVal.clone(); clonedVal.setParent(clone); clonedSet.add(clonedVal); } return clonedSet; }
public <IV extends PrismValue,ID extends ItemDefinition> Item<IV,ID> getParsedItem(ID itemDefinition, QName itemName) throws SchemaException { Validate.notNull(itemDefinition); Validate.notNull(itemName); Item<IV,ID> item = itemDefinition.instantiate(); IV newValue = getParsedValue(itemDefinition, itemName); if (newValue != null) { item.add((IV) newValue.clone()); } return item; }
public RawType clone() { RawType clone = new RawType(prismContext); if (xnode != null) { clone.xnode = xnode.clone(); } else if (parsed != null) { clone.parsed = parsed.clone(); } clone.explicitTypeName = explicitTypeName; clone.explicitTypeDeclaration = explicitTypeDeclaration; return clone; }
/** * Merge all the values of other item to this item. */ @Override public void merge(Item<V,D> otherItem) throws SchemaException { for (V otherValue: otherItem.getValues()) { if (!contains(otherValue)) { add((V) otherValue.clone()); } } }
private static void addRealValue(Item<PrismValue, ItemDefinition> extensionItem, Object value, PrismContext prismContext) throws SchemaException { if (value != null) { extensionItem.add(prismContext.itemFactory().createValue(value).clone()); } }
private static <V extends PrismValue> V cloneAndApplyMetadata(V value, boolean isAssignment, Supplier<String> originMappingNameSupplier) throws SchemaException { //noinspection unchecked V cloned = (V) value.clone(); if (isAssignment && cloned instanceof PrismContainerValue) { ((PrismContainerValue) cloned).setId(null); String originMappingName = originMappingNameSupplier.get(); LOGGER.trace("cloneAndApplyMetadata: originMappingName = {}", originMappingName); if (originMappingName != null) { //noinspection unchecked PrismContainer<MetadataType> metadataContainer = ((PrismContainerValue) cloned).findOrCreateContainer(AssignmentType.F_METADATA); metadataContainer.getValue().asContainerable().setOriginMappingName(originMappingName); } } return cloned; }
@NotNull Item getFilterItem() throws SchemaException { if (getDefinition() == null){ throw new SchemaException("Could not find definition for item " + getPath()); } Item filterItem = getDefinition().instantiate(); if (getValues() != null && !getValues().isEmpty()) { try { for (PrismValue v : getValues()){ filterItem.add(v.clone()); } } catch (SchemaException e) { throw new IllegalArgumentException(e.getMessage(), e); } } return filterItem; }
/** * Distributes the replace values of this delta to add and delete with * respect to provided existing values. */ public void distributeReplace(Collection<V> existingValues) { checkMutability(); Collection<V> origValuesToReplace = getValuesToReplace(); // We have to clear before we distribute, otherwise there will be replace/add or replace/delete conflict clearValuesToReplace(); if (existingValues != null) { for (V existingVal : existingValues) { if (!isIn(origValuesToReplace, existingVal)) { addValueToDelete((V) existingVal.clone()); } } } for (V replaceVal : origValuesToReplace) { if (!isIn(existingValues, replaceVal) && !isIn(getValuesToAdd(), replaceVal)) { addValueToAdd((V) replaceVal.clone()); } } }
@SuppressWarnings("unchecked") private void addToMinusIfNecessary(V originalValue) { if (outputTriple != null && (outputTriple.presentInPlusSet(originalValue) || outputTriple.presentInZeroSet(originalValue))) { return; } // remove it! if (outputTriple == null) { outputTriple = getPrismContext().deltaFactory().createPrismValueDeltaSetTriple(); } LOGGER.trace("Original value is in the mapping range (while not in mapping result), adding it to minus set: {}", originalValue); outputTriple.addToMinusSet((V)originalValue.clone()); }
/** * Merges the provided item into this item. The values are joined together. * Returns true if new item or value was added. */ public <IV extends PrismValue,ID extends ItemDefinition> boolean merge(Item<IV,ID> item) throws SchemaException { checkMutability(); Item<IV, ID> existingItem = findItem(item.getElementName(), Item.class); if (existingItem == null) { return add(item); } else { boolean changed = false; for (IV newVal: item.getValues()) { if (existingItem.add((IV) newVal.clone())) { changed = true; } } return changed; } }
public PrismValueDeltaSetTriple<V> toDeltaSetTriple(Item<V,D> itemOld) { PrismValueDeltaSetTriple<V> triple = new PrismValueDeltaSetTripleImpl<>(); if (isReplace()) { triple.getPlusSet().addAll(PrismValueCollectionsUtil.cloneCollection(getValuesToReplace())); if (itemOld != null) { triple.getMinusSet().addAll(PrismValueCollectionsUtil.cloneCollection(itemOld.getValues())); } return triple; } if (isAdd()) { triple.getPlusSet().addAll(PrismValueCollectionsUtil.cloneCollection(getValuesToAdd())); } if (isDelete()) { triple.getMinusSet().addAll(PrismValueCollectionsUtil.cloneCollection(getValuesToDelete())); } if (itemOld != null && itemOld.getValues() != null) { for (V itemVal: itemOld.getValues()) { if (!PrismValueCollectionsUtil.containsRealValue(valuesToDelete, itemVal) && !PrismValueCollectionsUtil .containsRealValue(valuesToAdd, itemVal)) { triple.getZeroSet().add((V) itemVal.clone()); } } } return triple; }
item.add(valueToAdd.clone(), false);
PrismValue pval = (PrismValue) value; if (!pval.isImmutable()) { PrismValue clone = pval.clone(); clone.setImmutable(true); return (T) clone;