Interface ItemDelta<V extends PrismValue,D extends ItemDefinition<?>>
-
- All Superinterfaces:
DebugDumpable
,Foreachable<V>
,Freezable
,Itemable
,PathVisitable
,PrismContextSensitive
,Serializable
,Visitable
- All Known Subinterfaces:
ContainerDelta<V>
,ItemDeltaDelegator<V,D>
,ProcessedObject.ProcessedObjectItemDelta<V,D>
,PropertyDelta<T>
,ReferenceDelta
- All Known Implementing Classes:
ContainerDeltaImpl
,ItemDeltaImpl
,PropertyDeltaImpl
,ReferenceDeltaImpl
public interface ItemDelta<V extends PrismValue,D extends ItemDefinition<?>> extends Itemable, DebugDumpable, Visitable, PathVisitable, Foreachable<V>, Serializable, Freezable, PrismContextSensitive
Item Delta describes a change of an item which is a property, container or a reference. It describes only a very small change - a change of a single item. Therefore complex changes can only be described by using several item deltas together.A group of item deltas is called modifications because they describe how an object is modified (they cannot apply to add or delete object delta). Item delta describes values that are being added, removed or replaced with respect to an item. Therefore the item delta may also be of several types:
- add of new values. The values in item delta are added to the existing values. Existing values are left as they are.
- delete of existing values. The values in item delta are removed from the set of existing values. Other existing values are left as they are.
- replace of the values. All existing values are removed and all the values in item delta are added.
-
-
Field Summary
-
Fields inherited from interface com.evolveum.midpoint.util.DebugDumpable
INDENT_STRING
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
accept(Visitor visitor)
void
accept(Visitor visitor, boolean includeOldValues)
void
accept(Visitor visitor, ItemPath path, boolean recursive)
void
addEstimatedOldValue(V newValue)
void
addEstimatedOldValues(Collection<V> newValues)
void
addEstimatedOldValues(V... newValues)
boolean
addsAnyValue()
void
addToReplaceDelta()
void
addValuesToAdd(Collection<V> newValues)
void
addValuesToAdd(V... newValues)
void
addValuesToDelete(Collection<V> newValues)
void
addValuesToDelete(V... newValues)
void
addValueToAdd(V newValue)
void
addValueToDelete(V newValue)
void
addValueToReplace(V newValue)
void
applyDefinition(D definition)
void
applyDefinition(D itemDefinition, boolean force)
void
applyTo(Item item)
void
applyTo(PrismContainerValue containerValue)
void
applyToMatchingPath(Item item)
Applies delta to item.void
assertDefinitions(boolean tolerateRawValues, Supplier<String> sourceDescriptionSupplier)
void
assertDefinitions(Supplier<String> sourceDescriptionSupplier)
void
checkConsistence()
void
checkConsistence(boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope)
void
checkConsistence(ConsistencyCheckScope scope)
void
clear()
void
clearValuesToAdd()
void
clearValuesToDelete()
void
clearValuesToReplace()
ItemDelta<V,D>
clone()
ItemDelta<V,D>
cloneWithChangedParentPath(ItemPath newParentPath)
boolean
contains(ItemDelta<V,D> other)
Returns true if the other delta is a complete subset of this delta.boolean
contains(ItemDelta<V,D> other, EquivalenceStrategy strategy)
Returns true if the other delta is a complete subset of this delta.ItemDelta<V,D>
createReverseDelta()
String
debugDump(int indent)
void
distributeReplace(Collection<V> existingValues)
Distributes the replace values of this delta to add and delete with respect to provided existing values.boolean
equals(Object obj)
boolean
equivalent(ItemDelta other)
Deltas are equivalent if they have the same result when applied to an object.void
filterValues(Function<V,Boolean> function)
void
filterYields(BiFunction<V,PrismContainerValue,Boolean> function)
V
findValueToAddOrReplace(V value)
void
foreach(Processor<V> processor)
Will call processor for every element in the instance.V
getAnyValue()
D
getDefinition()
ItemName
getElementName()
Collection<V>
getEstimatedOldValues()
Returns estimated state of the old value before the delta is applied.Class<? extends Item>
getItemClass()
Item<V,D>
getItemNew()
Returns the "new" state of the property - the state that would be after the delta is applied.Item<V,D>
getItemNew(Item<V,D> itemOld)
Returns the "new" state of the property - the state that would be after the delta is applied.Item<V,D>
getItemNewMatchingPath(Item<V,D> itemOld)
ItemPath
getParentPath()
@NotNull ItemPath
getPath()
default Collection<?>
getRealValuesToAdd()
default Collection<?>
getRealValuesToDelete()
default Collection<?>
getRealValuesToReplace()
ItemDelta<?,?>
getSubDelta(ItemPath path)
Collection<V>
getValueChanges(PlusMinusZero mode)
Collection<V>
getValuesToAdd()
Collection<V>
getValuesToDelete()
Collection<V>
getValuesToReplace()
boolean
hasCompleteDefinition()
boolean
isAdd()
boolean
isApplicableTo(Item item)
boolean
isDelete()
boolean
isEmpty()
static boolean
isEmpty(ItemDelta<?,?> itemDelta)
boolean
isImmutable()
boolean
isLiterallyEmpty()
The original semantics ofisEmpty()
method: returns true if all of values to add, delete, replace are null.default boolean
isOperational()
boolean
isRaw()
boolean
isRedundant(PrismObject<? extends Objectable> object, ParameterizedEquivalenceStrategy strategy, boolean assumeMissingItems)
Checks if the delta is redundant w.r.t.boolean
isReplace()
boolean
isValueToAdd(V value)
boolean
isValueToDelete(V value)
boolean
isValueToReplace(V value)
void
merge(ItemDelta<V,D> deltaToMerge)
Merge specified delta to this delta.void
mergeValuesToAdd(Collection<V> newValues)
void
mergeValuesToAdd(V[] newValues)
void
mergeValuesToDelete(Collection<V> newValues)
void
mergeValuesToDelete(V[] newValues)
void
mergeValuesToReplace(Collection<V> newValues)
void
mergeValuesToReplace(V[] newValues)
void
mergeValueToAdd(V newValue)
void
mergeValueToDelete(V newValue)
void
mergeValueToReplace(V newValue)
ItemDelta<V,D>
narrow(PrismObject<? extends Objectable> object, @NotNull Comparator<V> plusComparator, @NotNull Comparator<V> minusComparator, boolean assumeMissingItems)
Returns the narrowed delta that will have the same effect on the object as the current one.void
normalize()
boolean
removeValueToAdd(PrismValue valueToRemove)
boolean
removeValueToDelete(PrismValue valueToRemove)
boolean
removeValueToReplace(PrismValue valueToRemove)
void
resetValuesToAdd()
void
resetValuesToDelete()
void
resetValuesToReplace()
void
revive(PrismContext prismContext)
void
setDefinition(D definition)
void
setElementName(QName elementName)
void
setEstimatedOldValues(Collection<V> estimatedOldValues)
void
setOriginTypeRecursive(OriginType originType)
Set origin type to all values and subvaluesvoid
setParentPath(ItemPath parentPath)
void
setValuesToReplace(Collection<V> newValues)
void
setValuesToReplace(V... newValues)
void
setValueToReplace()
Sets empty value to replace.void
setValueToReplace(V newValue)
void
simplify()
Transforms the delta to the simplest (and safest) form.int
size()
PrismValueDeltaSetTriple<V>
toDeltaSetTriple(Item<V,D> itemOld)
String
toString()
void
validate()
void
validate(String contextDescription)
void
validateValues(ItemDeltaValidator<V> validator)
void
validateValues(ItemDeltaValidator<V> validator, Collection<V> oldValues)
-
Methods inherited from interface com.evolveum.midpoint.util.DebugDumpable
debugDump, debugDumpLazily, debugDumpLazily
-
Methods inherited from interface com.evolveum.midpoint.prism.Freezable
checkImmutable, checkMutable, freeze
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContextSensitive
getPrismContext
-
-
-
-
Method Detail
-
getElementName
ItemName getElementName()
- Specified by:
getElementName
in interfaceItemable
-
setElementName
void setElementName(QName elementName)
-
getParentPath
ItemPath getParentPath()
-
setParentPath
void setParentPath(ItemPath parentPath)
-
getDefinition
D getDefinition()
- Specified by:
getDefinition
in interfaceItemable
-
isOperational
default boolean isOperational()
-
setDefinition
void setDefinition(D definition)
-
accept
void accept(Visitor visitor)
- Specified by:
accept
in interfaceVisitable<V extends PrismValue>
-
accept
void accept(Visitor visitor, boolean includeOldValues)
-
size
int size()
-
accept
void accept(Visitor visitor, ItemPath path, boolean recursive)
- Specified by:
accept
in interfacePathVisitable
-
applyDefinition
void applyDefinition(D definition) throws SchemaException
- Throws:
SchemaException
-
hasCompleteDefinition
boolean hasCompleteDefinition()
-
getValuesToAdd
Collection<V> getValuesToAdd()
-
getRealValuesToAdd
default Collection<?> getRealValuesToAdd()
-
clearValuesToAdd
void clearValuesToAdd()
-
getValuesToDelete
Collection<V> getValuesToDelete()
-
getRealValuesToDelete
default Collection<?> getRealValuesToDelete()
-
clearValuesToDelete
void clearValuesToDelete()
-
getValuesToReplace
Collection<V> getValuesToReplace()
-
getRealValuesToReplace
default Collection<?> getRealValuesToReplace()
-
clearValuesToReplace
void clearValuesToReplace()
-
addValuesToAdd
void addValuesToAdd(Collection<V> newValues)
-
addValuesToAdd
void addValuesToAdd(V... newValues)
-
addValueToAdd
void addValueToAdd(V newValue)
-
removeValueToAdd
boolean removeValueToAdd(PrismValue valueToRemove)
-
removeValueToDelete
boolean removeValueToDelete(PrismValue valueToRemove)
-
removeValueToReplace
boolean removeValueToReplace(PrismValue valueToRemove)
-
mergeValuesToAdd
void mergeValuesToAdd(Collection<V> newValues)
-
mergeValuesToAdd
void mergeValuesToAdd(V[] newValues)
-
mergeValueToAdd
void mergeValueToAdd(V newValue)
-
addValuesToDelete
void addValuesToDelete(Collection<V> newValues)
-
addValuesToDelete
void addValuesToDelete(V... newValues)
-
addValueToDelete
void addValueToDelete(V newValue)
-
mergeValuesToDelete
void mergeValuesToDelete(Collection<V> newValues)
-
mergeValuesToDelete
void mergeValuesToDelete(V[] newValues)
-
mergeValueToDelete
void mergeValueToDelete(V newValue)
-
resetValuesToAdd
void resetValuesToAdd()
-
resetValuesToDelete
void resetValuesToDelete()
-
resetValuesToReplace
void resetValuesToReplace()
-
setValuesToReplace
void setValuesToReplace(Collection<V> newValues)
-
setValuesToReplace
void setValuesToReplace(V... newValues)
-
setValueToReplace
void setValueToReplace()
Sets empty value to replace. This efficiently means removing all values.
-
setValueToReplace
void setValueToReplace(V newValue)
-
addValueToReplace
void addValueToReplace(V newValue)
-
mergeValuesToReplace
void mergeValuesToReplace(Collection<V> newValues)
-
mergeValuesToReplace
void mergeValuesToReplace(V[] newValues)
-
mergeValueToReplace
void mergeValueToReplace(V newValue)
-
isValueToAdd
boolean isValueToAdd(V value)
-
isValueToDelete
boolean isValueToDelete(V value)
-
isValueToReplace
boolean isValueToReplace(V value)
-
getAnyValue
V getAnyValue()
-
isEmpty
boolean isEmpty()
-
isEmpty
static boolean isEmpty(ItemDelta<?,?> itemDelta)
-
isLiterallyEmpty
boolean isLiterallyEmpty()
The original semantics ofisEmpty()
method: returns true if all of values to add, delete, replace are null. TODO is this really needed?
-
addsAnyValue
boolean addsAnyValue()
-
foreach
void foreach(Processor<V> processor)
Description copied from interface:Foreachable
Will call processor for every element in the instance. This is NOT recursive. E.g. in case of collection of collections the processor will NOT be called for elements of the inner collections. If you need recursion please have a look at Visitor.- Specified by:
foreach
in interfaceForeachable<V extends PrismValue>
-
getEstimatedOldValues
Collection<V> getEstimatedOldValues()
Returns estimated state of the old value before the delta is applied. This information is not entirely reliable. The state might change between the value is read and the delta is applied. This is property is optional and even if provided it is only for for informational purposes.If this method returns null then it should be interpreted as "I do not know". In that case the delta has no information about the old values. If this method returns empty collection then it should be interpreted that we know that there were no values in this item before the delta was applied.
- Returns:
- estimated state of the old value before the delta is applied (may be null).
-
setEstimatedOldValues
void setEstimatedOldValues(Collection<V> estimatedOldValues)
-
addEstimatedOldValues
void addEstimatedOldValues(Collection<V> newValues)
-
addEstimatedOldValues
void addEstimatedOldValues(V... newValues)
-
addEstimatedOldValue
void addEstimatedOldValue(V newValue)
-
normalize
void normalize()
-
isReplace
boolean isReplace()
-
isAdd
boolean isAdd()
-
isDelete
boolean isDelete()
-
clear
void clear()
-
narrow
ItemDelta<V,D> narrow(PrismObject<? extends Objectable> object, @NotNull @NotNull Comparator<V> plusComparator, @NotNull @NotNull Comparator<V> minusComparator, boolean assumeMissingItems)
Returns the narrowed delta that will have the same effect on the object as the current one.We can skip deletion of vDel if there is no vEx ~ vDel (under minusComparator).
We can skip addition of vAdd if there is existing vEx ~ vAdd (under plusComparator). But if we do that we must be sure to skip deletion of all vDel ~ vAdd (under minusComparator). Otherwise we would delete vDel but fail to add equivalent vAdd.
We can skip replacing of a set of values if and only if existing item has equivalent values under plusComparator.
This reasoning is bound to the actual application algorithm in ItemDeltaImpl. But we should be aware that there are deltas that are applied by other code, e.g. those than are applied on a resource.
- Parameters:
plusComparator
- Comparator we want to use when determining skippability of values being added.minusComparator
- Comparator we want to use when determining skippability of values being deleted.
-
isRedundant
boolean isRedundant(PrismObject<? extends Objectable> object, ParameterizedEquivalenceStrategy strategy, boolean assumeMissingItems)
Checks if the delta is redundant w.r.t. current state of the object. I.e. if it changes the current object state.- Parameters:
assumeMissingItems
- Assumes that some items in the object may be missing. So delta that replaces them by null
-
validate
void validate() throws SchemaException
- Throws:
SchemaException
-
validate
void validate(String contextDescription) throws SchemaException
- Throws:
SchemaException
-
validateValues
void validateValues(ItemDeltaValidator<V> validator) throws SchemaException
- Throws:
SchemaException
-
validateValues
void validateValues(ItemDeltaValidator<V> validator, Collection<V> oldValues) throws SchemaException
- Throws:
SchemaException
-
checkConsistence
void checkConsistence()
-
checkConsistence
void checkConsistence(ConsistencyCheckScope scope)
-
checkConsistence
void checkConsistence(boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope)
-
distributeReplace
void distributeReplace(Collection<V> existingValues)
Distributes the replace values of this delta to add and delete with respect to provided existing values.
-
merge
void merge(ItemDelta<V,D> deltaToMerge)
Merge specified delta to this delta. This delta is assumed to be chronologically earlier, delta provided in the parameter is chronologically later.TODO do we expect that the paths of "this" delta and deltaToMerge are the same? From the code it seems so.
-
getValueChanges
Collection<V> getValueChanges(PlusMinusZero mode)
-
simplify
void simplify()
Transforms the delta to the simplest (and safest) form. E.g. it will transform add delta for single-value properties to replace delta.
-
applyTo
void applyTo(PrismContainerValue containerValue) throws SchemaException
- Throws:
SchemaException
-
applyTo
void applyTo(Item item) throws SchemaException
- Throws:
SchemaException
-
applyToMatchingPath
void applyToMatchingPath(Item item) throws SchemaException
Applies delta to item. Assumes that path of the delta and path of the item matches (does not do path checks).- Throws:
SchemaException
-
isApplicableTo
boolean isApplicableTo(Item item)
-
getItemNew
Item<V,D> getItemNew() throws SchemaException
Returns the "new" state of the property - the state that would be after the delta is applied.- Throws:
SchemaException
-
getItemNew
Item<V,D> getItemNew(Item<V,D> itemOld) throws SchemaException
Returns the "new" state of the property - the state that would be after the delta is applied.- Throws:
SchemaException
-
getItemNewMatchingPath
Item<V,D> getItemNewMatchingPath(Item<V,D> itemOld) throws SchemaException
- Throws:
SchemaException
-
contains
boolean contains(ItemDelta<V,D> other)
Returns true if the other delta is a complete subset of this delta. I.e. if all the statements of the other delta are already contained in this delta. As a consequence it also returns true if the two deltas are equal.
-
contains
boolean contains(ItemDelta<V,D> other, EquivalenceStrategy strategy)
Returns true if the other delta is a complete subset of this delta. I.e. if all the statements of the other delta are already contained in this delta. As a consequence it also returns true if the two deltas are equal.
-
filterYields
void filterYields(BiFunction<V,PrismContainerValue,Boolean> function)
-
toDeltaSetTriple
PrismValueDeltaSetTriple<V> toDeltaSetTriple(Item<V,D> itemOld) throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(Supplier<String> sourceDescriptionSupplier) throws SchemaException
- Throws:
SchemaException
-
assertDefinitions
void assertDefinitions(boolean tolerateRawValues, Supplier<String> sourceDescriptionSupplier) throws SchemaException
- Throws:
SchemaException
-
isRaw
boolean isRaw()
-
revive
void revive(PrismContext prismContext) throws SchemaException
- Throws:
SchemaException
-
applyDefinition
void applyDefinition(D itemDefinition, boolean force) throws SchemaException
- Throws:
SchemaException
-
equivalent
boolean equivalent(ItemDelta other)
Deltas are equivalent if they have the same result when applied to an object. I.e. meta-data and other "decorations" such as old values are not considered in this comparison.
-
debugDump
String debugDump(int indent)
- Specified by:
debugDump
in interfaceDebugDumpable
-
addToReplaceDelta
void addToReplaceDelta()
-
setOriginTypeRecursive
void setOriginTypeRecursive(OriginType originType)
Set origin type to all values and subvalues
-
isImmutable
boolean isImmutable()
- Specified by:
isImmutable
in interfaceFreezable
-
-