Interface ObjectDelta<O extends Objectable>

All Superinterfaces:
Cloneable, DebugDumpable, Freezable, PathVisitable, PrismContextSensitive, Serializable, Visitable
All Known Subinterfaces:
ShadowCoordinatesQualifiedObjectDelta<T>
All Known Implementing Classes:
ObjectDeltaImpl, ShadowCoordinatesQualifiedObjectDeltaImpl

Relative difference (delta) of the object. This class describes how the object changes. It can describe either object addition, modification of deletion.
  • Addition describes complete new (absolute) state of the object.
  • Modification contains a set property deltas that describe relative changes to individual properties
  • Deletion does not contain anything. It only marks object for deletion.
The OID is mandatory for modification and deletion.

See this document for more.

Author:
Radovan Semancik
See Also:
  • Method Details

    • accept

      void accept(Visitor visitor, boolean includeOldValues)
    • accept

      void accept(Visitor visitor, ItemPath path, boolean recursive)
      Specified by:
      accept in interface PathVisitable
    • getChangeType

      ChangeType getChangeType()
    • setChangeType

      void setChangeType(ChangeType changeType)
    • isAdd

      static boolean isAdd(ObjectDelta<?> objectDelta)
    • isAdd

      boolean isAdd()
    • isDelete

      static boolean isDelete(ObjectDelta<?> objectDelta)
    • isDelete

      boolean isDelete()
    • isModify

      static boolean isModify(ObjectDelta<?> objectDelta)
    • isModify

      boolean isModify()
    • getOid

      String getOid()
    • setOid

      void setOid(String oid)
    • setPrismContext

      void setPrismContext(PrismContext prismContext)
    • getObjectToAdd

      PrismObject<O> getObjectToAdd()
    • setObjectToAdd

      void setObjectToAdd(PrismObject<O> objectToAdd)
    • getModifications

      @NotNull @NotNull Collection<? extends ItemDelta<?,?>> getModifications()
    • addModification

      <D extends ItemDelta> D addModification(D itemDelta)
      Adds modification (itemDelta) and returns the modification that was added. NOTE: the modification that was added may be different from the modification that was passed into this method! E.g. in case if two modifications must be merged to keep the delta consistent. Therefore always use the returned modification after this method is invoked.
    • deleteModification

      @Experimental boolean deleteModification(ItemDelta<?,?> itemDelta)
      Deletes a modification, if it exists in a given MODIFY delta. (Throws an exception if the delta is not a MODIFY one.)
      Returns:
      true if the modification was found and removed
    • containsModification

      boolean containsModification(ItemDelta itemDelta, EquivalenceStrategy strategy)
    • containsAllModifications

      boolean containsAllModifications(Collection<? extends ItemDelta<?,?>> itemDeltas, EquivalenceStrategy strategy)
    • addModifications

      void addModifications(Collection<? extends ItemDelta> itemDeltas)
    • addModifications

      void addModifications(ItemDelta<?,?>... itemDeltas)
    • findItemDelta

      <IV extends PrismValue, ID extends ItemDefinition<?>> ItemDelta<IV,ID> findItemDelta(ItemPath itemPath)
      TODO specify this method!

      An attempt:

      Given this ADD or MODIFY object delta OD, finds an item delta ID such that "ID has the same effect on an item specified by itemPath as OD" (simply said).

      More precisely, - if OD is ADD delta: ID is ADD delta that adds values of the item present in the object being added - if OD is MODIFY delta: ID is such delta that: 1. Given ANY object O, let O' be O after application of OD. 2. Let I be O(itemPath), I' be O'(itemPath). 3. Then I' is the same as I after application of ID. ID is null if no such item delta exists - or cannot be found easily.

      Problem: - If OD contains more than one modification that affects itemPath the results from findItemDelta can be differ from the above definition.

    • findItemDelta

      <IV extends PrismValue, ID extends ItemDefinition<?>> ItemDelta<IV,ID> findItemDelta(ItemPath itemPath, boolean strict)
    • findItemDelta

      <IV extends PrismValue, ID extends ItemDefinition<?>, I extends Item<IV, ID>, DD extends ItemDelta<IV, ID>> DD findItemDelta(ItemPath itemPath, Class<DD> deltaType, Class<I> itemType, boolean strict)
    • findPartial

      <IV extends PrismValue, ID extends ItemDefinition<?>> Collection<PartiallyResolvedDelta<IV,ID>> findPartial(ItemPath propertyPath)
    • hasItemDelta

      boolean hasItemDelta(ItemPath propertyPath)
    • hasItemOrSubitemDelta

      boolean hasItemOrSubitemDelta(ItemPath propertyPath)
    • hasRelatedDelta

      boolean hasRelatedDelta(ItemPath itemPath)
      Returns `true` if the delta may have an effect on the specified item. - For `ADD` deltas, returns `true` if the object has the specified item. - For `DELETE` deltas, returns `false` (as we don't know the object). - For `MODIFY` deltas, returns `true` if there is any overlap between the specified item and the modified items (either exact match, sub- or super-path match). May not be quite precise when multivalued containers are involved, e.g. if we are asking about `assignment[1]/targetRef` and the delta contains an addition of `assignment` with a different PCV ID, e.g. [2]. The result would be a false positive.
    • hasCompleteDefinition

      boolean hasCompleteDefinition()
    • getObjectTypeClass

      Class<O> getObjectTypeClass()
    • setObjectTypeClass

      void setObjectTypeClass(Class<O> objectTypeClass)
    • findPropertyDelta

      <X> PropertyDelta<X> findPropertyDelta(ItemPath parentPath, QName propertyName)
      Top-level path is assumed.
    • findPropertyDelta

      <X> PropertyDelta<X> findPropertyDelta(ItemPath propertyPath)
    • findContainerDelta

      <X extends Containerable> ContainerDelta<X> findContainerDelta(ItemPath propertyPath)
    • findReferenceModification

      ReferenceDelta findReferenceModification(ItemPath itemPath)
    • findItemDeltasSubPath

      @NotNull @NotNull Collection<? extends ItemDelta<?,?>> findItemDeltasSubPath(ItemPath itemPath)
      Returns all item deltas at or below a specified path.
    • removeModification

      void removeModification(ItemDelta<?,?> itemDelta)
    • removeReferenceModification

      void removeReferenceModification(ItemPath itemPath)
    • removeContainerModification

      void removeContainerModification(ItemPath itemName)
    • removePropertyModification

      void removePropertyModification(ItemPath itemPath)
    • isEmpty

      boolean isEmpty()
    • normalize

      void normalize()
    • narrow

      ObjectDelta<O> narrow(PrismObject<O> existingObject, @NotNull @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems)
    • applyDefinitionIfPresent

      void applyDefinitionIfPresent(PrismObjectDefinition<O> definition, boolean tolerateNoDefinition) throws SchemaException
      Throws:
      SchemaException
    • clone

      ObjectDelta<O> clone()
      Deep clone.
    • merge

      void merge(ObjectDelta<O> deltaToMerge) throws SchemaException
      Merge provided delta into this delta. This delta is assumed to be chronologically earlier, delta in the parameter is assumed to come chronologicaly later.
      Throws:
      SchemaException
    • mergeModifications

      void mergeModifications(Collection<? extends ItemDelta> modificationsToMerge) throws SchemaException
      Throws:
      SchemaException
    • mergeModification

      void mergeModification(ItemDelta<?,?> modificationToMerge) throws SchemaException
      Throws:
      SchemaException
    • applyTo

      void applyTo(PrismObject<O> targetObject) throws SchemaException
      Applies this object delta to specified object, returns updated object. It modifies the provided object.
      Throws:
      SchemaException
    • computeChangedObject

      PrismObject<O> computeChangedObject(PrismObject<O> objectOld) throws SchemaException
      Applies this object delta to specified object, returns updated object. It leaves the original object unchanged.
      Parameters:
      objectOld - object before change
      Returns:
      object with applied changes or null if the object should not exit (was deleted)
      Throws:
      SchemaException
    • swallow

      void swallow(ItemDelta<?,?> newItemDelta) throws SchemaException
      Incorporates the property delta into the existing property deltas (regardless of the change type).
      Throws:
      SchemaException
    • swallow

      void swallow(List<ItemDelta<?,?>> itemDeltas) throws SchemaException
      Throws:
      SchemaException
    • createPropertyModification

      <X> PropertyDelta<X> createPropertyModification(ItemPath path)
    • createPropertyModification

      <C> PropertyDelta<C> createPropertyModification(ItemPath path, PrismPropertyDefinition propertyDefinition)
    • createReferenceModification

      ReferenceDelta createReferenceModification(ItemPath path, PrismReferenceDefinition referenceDefinition)
    • createContainerModification

      <C extends Containerable> ContainerDelta<C> createContainerModification(ItemPath path)
    • createContainerModification

      <C extends Containerable> ContainerDelta<C> createContainerModification(ItemPath path, PrismContainerDefinition<C> containerDefinition)
    • addModificationReplaceProperty

      <X> PropertyDelta<X> addModificationReplaceProperty(ItemPath propertyPath, X... propertyValues)
    • addModificationAddProperty

      <X> void addModificationAddProperty(ItemPath propertyPath, X... propertyValues)
    • addModificationDeleteProperty

      <X> void addModificationDeleteProperty(ItemPath propertyPath, X... propertyValues)
    • addModificationAddContainer

      <C extends Containerable> void addModificationAddContainer(ItemPath propertyPath, C... containerables) throws SchemaException
      Throws:
      SchemaException
    • addModificationAddContainer

      <C extends Containerable> void addModificationAddContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
    • addModificationDeleteContainer

      <C extends Containerable> void addModificationDeleteContainer(ItemPath propertyPath, C... containerables) throws SchemaException
      Throws:
      SchemaException
    • addModificationDeleteContainer

      <C extends Containerable> void addModificationDeleteContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
    • addModificationReplaceContainer

      <C extends Containerable> void addModificationReplaceContainer(ItemPath propertyPath, PrismContainerValue<C>... containerValues)
    • addModificationAddReference

      void addModificationAddReference(ItemPath path, PrismReferenceValue... refValues)
    • addModificationDeleteReference

      void addModificationDeleteReference(ItemPath path, PrismReferenceValue... refValues)
    • addModificationReplaceReference

      void addModificationReplaceReference(ItemPath path, PrismReferenceValue... refValues)
    • createReferenceModification

      ReferenceDelta createReferenceModification(ItemPath refPath)
    • createReverseDelta

      ObjectDelta<O> createReverseDelta() throws SchemaException
      Throws:
      SchemaException
    • checkConsistence

      void checkConsistence()
    • checkConsistence

      void checkConsistence(ConsistencyCheckScope scope)
    • checkConsistence

      void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw)
    • checkConsistence

      void checkConsistence(boolean requireOid, boolean requireDefinition, boolean prohibitRaw, ConsistencyCheckScope scope)
    • assertDefinitions

      void assertDefinitions() throws SchemaException
      Throws:
      SchemaException
    • assertDefinitions

      void assertDefinitions(Supplier<String> sourceDescription) throws SchemaException
      Throws:
      SchemaException
    • assertDefinitions

      void assertDefinitions(boolean tolerateRawElements) throws SchemaException
      Throws:
      SchemaException
    • assertDefinitions

      void assertDefinitions(boolean tolerateRawElements, Supplier<String> sourceDescription) throws SchemaException
      Assert that all the items has appropriate definition.
      Throws:
      SchemaException
    • revive

      void revive(PrismContext prismContext) throws SchemaException
      Throws:
      SchemaException
    • applyDefinition

      void applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force) throws SchemaException
      Throws:
      SchemaException
    • equivalent

      boolean equivalent(ObjectDelta other)
    • toDebugType

      String toDebugType()
      Returns short string identification of object type. It should be in a form suitable for log messages. There is no requirement for the type name to be unique, but it rather has to be compact. E.g. short element names are preferred to long QNames or URIs.
    • isEmpty

      static boolean isEmpty(ObjectDelta delta)
    • subtract

      ObjectDelta<O> subtract(@NotNull @NotNull Collection<ItemPath> paths)
      Returns modifications that are related to the given paths; removes them from the original delta. Applicable only to modify deltas. Currently compares paths by "equals" predicate -- in the future we might want to treat sub/super/equivalent paths! So consider this method highly experimental.
    • isRedundant

      boolean isRedundant(PrismObject<O> object, @NotNull @NotNull ParameterizedEquivalenceStrategy plusStrategy, @NotNull @NotNull ParameterizedEquivalenceStrategy minusStrategy, boolean assumeMissingItems) throws SchemaException
      Check if delta is redundant w.r.t. given object - i.e. if its application would have no visible effect on that object.
      Throws:
      SchemaException
    • removeOperationalItems

      @Experimental void removeOperationalItems()
    • removeEstimatedOldValues

      @Experimental void removeEstimatedOldValues()
    • isOfType

      default boolean isOfType(@NotNull @NotNull Class<? extends Objectable> objectType)
      Checks if the delta is of given type (including subtypes).
    • factorOut

      @NotNull @NotNull ObjectDelta.FactorOutResultSingle<O> factorOut(Collection<? extends ItemPath> paths, boolean cloneDelta)
    • factorOutValues

      @NotNull @NotNull ObjectDelta.FactorOutResultMulti<O> factorOutValues(ItemPath path, boolean cloneDelta) throws SchemaException
      Throws:
      SchemaException
    • subtract

      boolean subtract(@NotNull @NotNull ItemPath itemPath, @NotNull @NotNull PrismValue value, boolean fromMinusSet, boolean dryRun)
      Checks if the delta tries to add (or set) a 'value' for the item identified by 'itemPath'. If yes, it removes it.

      TODO consider changing return value to 'incremental delta' (or null)

      Parameters:
      dryRun - only testing if value could be subtracted; not changing anything
      Returns:
      true if the delta originally contained an instruction to add (or set) 'itemPath' to 'value'.
    • getModifiedItems

      @NotNull @NotNull List<ItemPath> getModifiedItems()
    • getNewValuesFor

      List<PrismValue> getNewValuesFor(ItemPath itemPath)
    • getDeletedValuesFor

      List<PrismValue> getDeletedValuesFor(ItemPath itemPath)
      Limitations: (1) For DELETE object delta, we don't know what values were in the object's item. (2) For REPLACE item delta, we don't know what values were in the object's item (but these deltas are quite rare for multivalued items; and eventually there will be normalized into ADD+DELETE form) (3) For DELETE item delta for PrismContainers, content of items deleted might not be known (only ID could be provided on PCVs).
    • clear

      void clear()
    • isImmutable

      boolean isImmutable()
      Specified by:
      isImmutable in interface Freezable
    • toDeltaSetTriple

      Creates PrismValueDeltaSetTriple (plus/minus/zero sets) for the value of PrismObject. Quite inefficient, as uses object cloning.
      Throws:
      SchemaException