private boolean removeValue(PrismValue valueToRemove, Collection<V> set, boolean toDelete) { checkMutability(); boolean removed = false; if (set == null) { return false; } Iterator<V> valuesIterator = set.iterator(); while (valuesIterator.hasNext()) { V existingValue = valuesIterator.next(); if (existingValue.equals(valueToRemove, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS) || toDelete && existingValue.representsSameValue(valueToRemove, false)) { // the same algorithm as when deleting the item value valuesIterator.remove(); removed = true; } } return removed; }
@Override public boolean remove(V value, @NotNull EquivalenceStrategy strategy) { checkMutability(); boolean changed = false; Iterator<V> iterator = values.iterator(); while (iterator.hasNext()) { V val = iterator.next(); if (val.representsSameValue(value, false) || val.equals(value, strategy)) { iterator.remove(); val.setParent(null); changed = true; } } return changed; }
public boolean remove(V newValue) { checkMutability(); boolean changed = false; Iterator<V> iterator = values.iterator(); while (iterator.hasNext()) { V val = iterator.next(); // the same algorithm as when deleting the item value from delete delta if (val.representsSameValue(newValue, false) || val.equals(newValue, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS)) { iterator.remove(); val.setParent(null); changed = true; } } return changed; }
private boolean equivalentSetRealValue(Collection<V> thisValue, Collection<V> otherValues, boolean isDelete) { return MiscUtil.unorderedCollectionEquals(thisValue, otherValues, (v1, v2) -> { if (v1 != null && v2 != null) { if (!isDelete || !(v1 instanceof PrismContainerValue) || !(v2 instanceof PrismContainerValue)) { // Here it is questionable if we should consider adding "assignment id=1 (A)" and "assignment id=2 (A)" // - i.e. assignments with the same real value but different identifiers - the same delta. // Historically, we considered it as such. But the question is if it's correct. return v1.equals(v2, EquivalenceStrategy.REAL_VALUE); } else { // But for container values to be deleted, they can be referred to either using IDs or values. // If content is used - but no IDs - the content must be equal. // If IDs are used - and are the same - the content is irrelevant. // The problem is if one side has content with ID, and the other has the same content without ID. // This might have the same or different effect, depending on the content it is applied to. // See MID-3828 return v1.equals(v2, EquivalenceStrategy.REAL_VALUE_CONSIDER_DIFFERENT_IDS) || v1.representsSameValue(v2, false); } } else { return false; } }); }
while (iterator.hasNext()) { PrismValueImpl otherValue = (PrismValueImpl) iterator.next(); if (thisValue.representsSameValue(otherValue, true)) { found = true;