Package org.eclipse.emf.compare.merge
Class ReferenceChangeMerger
java.lang.Object
org.eclipse.emf.compare.merge.AbstractMerger
org.eclipse.emf.compare.merge.ReferenceChangeMerger
- All Implemented Interfaces:
IMergeCriterionAware,IMergeOptionAware,IMerger,IMerger2
- Direct Known Subclasses:
AdditiveReferenceChangeMerger
This specific implementation of
AbstractMerger will be used to merge reference changes.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.emf.compare.merge.IMerger
IMerger.Registry, IMerger.Registry2, IMerger.RegistryImpl -
Field Summary
Fields inherited from class org.eclipse.emf.compare.merge.AbstractMerger
mergeOptions, SUB_DIFF_AWARE_OPTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidMerge the given difference accepting it.protected voidaddInTarget(ReferenceChange diff, boolean rightToLeft) This will be called when we need to create an element in the target side.booleanapply(IMergeCriterion criterion) Default implementation of apply for mergers that extends this class.protected voidcheckImpliedDiffsOrdering(ReferenceChange diff, boolean rightToLeft) In the case of many-to-many eOpposite references, EMF will simply report the difference made on one side of the equivalence to the other, without considering ordering in any way.protected voiddoMove(ReferenceChange diff, Comparison comparison, EObject expectedContainer, EObject expectedValue, boolean rightToLeft) This will do the actual work of moving the element into its reference.protected intfindInsertionIndex(Comparison comparison, Diff diff, boolean rightToLeft) This will be used by the distinct merge actions in order to find the index at which a value should be inserted in its target list.protected EObjectfindMatchIn(Comparison comparison, List<EObject> list, EObject element) Seeks a match of the givenelementin the given list, using the equality helper to find it.booleanisMergerFor(Diff target) Check if the merger is a good candidate to merge the given difference.protected voidmoveElement(ReferenceChange diff, boolean rightToLeft) This will be called when trying to copy a "MOVE" diff.protected voidMerge the given difference rejecting it.protected voidremoveFromTarget(ReferenceChange diff, boolean rightToLeft) This will be called when we need to remove an element from the target side.protected voidresetInTarget(ReferenceChange diff, boolean rightToLeft) This will be called by the merge operations in order to reset a reference to its original value, be that the left or right side.Methods inherited from class org.eclipse.emf.compare.merge.AbstractMerger
addAt, copyDiff, copyLeftToRight, copyRightToLeft, createCopy, getDirectMergeDependencies, getDirectResultingMerges, getDirectResultingRejections, getImpliedMerges, getLogicallyResultingMerges, getMergeOptions, getMergerDelegate, getMergerDelegate, getRanking, getRegistry, isAccepting, isAdd, isInTerminalState, isSet, isUnset, mergeDiff, setMergeOptions, setRanking, setRegistry
-
Constructor Details
-
ReferenceChangeMerger
public ReferenceChangeMerger()
-
-
Method Details
-
isMergerFor
Check if the merger is a good candidate to merge the given difference.- Parameters:
target- The given target difference.- Returns:
- True if it is the good candidate, false otherwise.
- See Also:
-
apply
Description copied from class:AbstractMergerDefault implementation of apply for mergers that extends this class. Will acceptnullor AdditiveMergeCriterion.INSTANCE.- Specified by:
applyin interfaceIMergeCriterionAware- Overrides:
applyin classAbstractMerger- Parameters:
criterion- The merge criterion- Returns:
trueif the given criterion is null or is AdditiveMergeCriterion.INSTANCE.
-
reject
Merge the given difference rejecting it.- Overrides:
rejectin classAbstractMerger- Parameters:
diff- The difference to merge.rightToLeft- The direction of the merge.
-
accept
Merge the given difference accepting it.- Overrides:
acceptin classAbstractMerger- Parameters:
diff- The difference to merge.rightToLeft- The direction of the merge.
-
moveElement
This will be called when trying to copy a "MOVE" diff.- Parameters:
diff- The diff we are currently merging.rightToLeft- Whether we should move the value in the left or right side.
-
doMove
protected void doMove(ReferenceChange diff, Comparison comparison, EObject expectedContainer, EObject expectedValue, boolean rightToLeft) This will do the actual work of moving the element into its reference. All sanity checks were made inand no more verification will be made here.invalid reference
#moveElement(boolean)- Parameters:
diff- The diff we are currently merging.comparison- Comparison holding this Diff.expectedContainer- The container in which we are reorganizing a reference.expectedValue- The value that is to be moved within its reference.rightToLeft- Whether we should move the value in the left or right side.
-
addInTarget
This will be called when we need to create an element in the target side.All necessary sanity checks have been made to ensure that the current operation is one that should create an object in its side or add an objet to a reference. In other words, either :
- We are copying from right to left and
- we are copying an addition to the right side (we need to create the same object in the left), or
- we are copying a deletion from the left side (we need to revert the deletion).
- We are copying from left to right and
- we are copying a deletion from the right side (we need to revert the deletion), or
- we are copying an addition to the left side (we need to create the same object in the right).
- Parameters:
diff- The diff we are currently merging.rightToLeft- Tells us whether we are to add an object on the left or right side.
- We are copying from right to left and
-
removeFromTarget
This will be called when we need to remove an element from the target side.All necessary sanity checks have been made to ensure that the current operation is one that should delete an object. In other words, we are :
- Copying from right to left and either
- we are copying a deletion from the right side (we need to remove the same object in the left) or,
- we are copying an addition to the left side (we need to revert the addition).
- Copying from left to right and either
- we are copying an addition to the right side (we need to revert the addition), or.
- we are copying a deletion from the left side (we need to remove the same object in the right).
- Parameters:
diff- The diff we are currently merging.rightToLeft- Tells us whether we are to add an object on the left or right side.
- Copying from right to left and either
-
resetInTarget
This will be called by the merge operations in order to reset a reference to its original value, be that the left or right side.Should never be called on multi-valued references.
- Parameters:
diff- The diff we are currently merging.rightToLeft- Tells us the direction of this merge operation.
-
checkImpliedDiffsOrdering
In the case of many-to-many eOpposite references, EMF will simply report the difference made on one side of the equivalence to the other, without considering ordering in any way. In such cases, we'll iterate over our equivalences after the merge, and double-check the ordering ourselves, fixing it as needed.Note that both implied and equivalent diffs will be double-checked from here.
- Parameters:
diff- The diff we are currently merging.rightToLeft- Direction of the merge.- Since:
- 3.1
-
findMatchIn
Seeks a match of the givenelementin the given list, using the equality helper to find it. This is only used when moving or deleting proxies for now.- Parameters:
comparison- The comparison which Diff we are currently merging.list- The list from which we seek a value.element- The value for which we need a match inlist.- Returns:
- The match of
elementinlist,nullif none.
-
findInsertionIndex
This will be used by the distinct merge actions in order to find the index at which a value should be inserted in its target list. SeeDiffUtil.findInsertionIndex(Comparison, Diff, boolean)for more on this.Sub-classes can override this if the insertion order is irrelevant. A return value of
-1will be considered as "no index" and the value will be inserted at the end of its target list.- Parameters:
comparison- This will be used in order to retrieve the Match for EObjects when comparing them.diff- The diff which merging will trigger the need for an insertion index in its target list.rightToLeft-trueif the merging will be done into the left list, so that we should consider the right model as the source and the left as the target.- Returns:
- The index at which this
diff's value should be inserted into the 'target' list, as inferred fromrightToLeft.-1if the value should be inserted at the end of its target list. - See Also:
-