public class ReferenceChangeMerger extends AbstractMerger
AbstractMerger
will be used to merge reference changes.IMerger.Registry, IMerger.Registry2, IMerger.RegistryImpl
mergeOptions, SUB_DIFF_AWARE_OPTION
Constructor and Description |
---|
ReferenceChangeMerger() |
Modifier and Type | Method and Description |
---|---|
protected void |
accept(Diff diff,
boolean rightToLeft)
Merge the given difference accepting it.
|
protected void |
addInTarget(ReferenceChange diff,
boolean rightToLeft)
This will be called when we need to create an element in the target side.
|
boolean |
apply(IMergeCriterion criterion)
Default implementation of apply for mergers that extends this class.
|
protected void |
checkImpliedDiffsOrdering(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 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.
|
protected int |
findInsertionIndex(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 EObject |
findMatchIn(Comparison comparison,
List<EObject> list,
EObject element)
Seeks a match of the given
element in the given list, using the equality helper to find it. |
boolean |
isMergerFor(Diff target)
Check if the merger is a good candidate to merge the given difference.
|
protected void |
moveElement(ReferenceChange diff,
boolean rightToLeft)
This will be called when trying to copy a "MOVE" diff.
|
protected void |
reject(Diff diff,
boolean rightToLeft)
Merge the given difference rejecting it.
|
protected void |
removeFromTarget(ReferenceChange diff,
boolean rightToLeft)
This will be called when we need to remove an element from the target side.
|
protected void |
resetInTarget(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.
|
addAt, copyDiff, copyLeftToRight, copyRightToLeft, createCopy, getDirectMergeDependencies, getDirectResultingMerges, getDirectResultingRejections, getImpliedMerges, getLogicallyResultingMerges, getMergeOptions, getMergerDelegate, getMergerDelegate, getRanking, getRegistry, isAccepting, isAdd, isInTerminalState, isSet, isUnset, mergeDiff, setMergeOptions, setRanking, setRegistry
public boolean isMergerFor(Diff target)
target
- The given target difference.IMerger.isMergerFor(org.eclipse.emf.compare.Diff)
public boolean apply(IMergeCriterion criterion)
AbstractMerger
null
or
AdditiveMergeCriterion.INSTANCE.apply
in interface IMergeCriterionAware
apply
in class AbstractMerger
criterion
- The merge criteriontrue
if the given criterion is null or is AdditiveMergeCriterion.INSTANCE.protected void reject(Diff diff, boolean rightToLeft)
reject
in class AbstractMerger
diff
- The difference to merge.rightToLeft
- The direction of the merge.protected void accept(Diff diff, boolean rightToLeft)
accept
in class AbstractMerger
diff
- The difference to merge.rightToLeft
- The direction of the merge.protected void moveElement(ReferenceChange diff, boolean rightToLeft)
diff
- The diff we are currently merging.rightToLeft
- Whether we should move the value in the left or right side.protected void doMove(ReferenceChange diff, Comparison comparison, EObject expectedContainer, EObject expectedValue, boolean rightToLeft)
#moveElement(boolean)
and no more verification will be made here.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.protected void addInTarget(ReferenceChange diff, boolean rightToLeft)
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 :
diff
- The diff we are currently merging.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected void removeFromTarget(ReferenceChange diff, boolean rightToLeft)
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 :
diff
- The diff we are currently merging.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected void resetInTarget(ReferenceChange diff, boolean rightToLeft)
Should never be called on multi-valued references.
diff
- The diff we are currently merging.rightToLeft
- Tells us the direction of this merge operation.protected void checkImpliedDiffsOrdering(ReferenceChange diff, boolean rightToLeft)
Note that both implied and equivalent diffs will be double-checked from here.
diff
- The diff we are currently merging.rightToLeft
- Direction of the merge.protected EObject findMatchIn(Comparison comparison, List<EObject> list, EObject element)
element
in the given list, using the equality helper to find it.
This is only used when moving or deleting proxies for now.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 in list
.element
in list
, null
if none.protected int findInsertionIndex(Comparison comparison, Diff diff, boolean rightToLeft)
DiffUtil.findInsertionIndex(Comparison, Diff, boolean)
for
more on this.
Sub-classes can override this if the insertion order is irrelevant. A return value of -1
will
be considered as "no index" and the value will be inserted at the end of its target list.
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
- true
if 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.diff
's value should be inserted into the 'target' list, as
inferred from rightToLeft
. -1
if the value should be inserted at the end of its
target list.DiffUtil.findInsertionIndex(Comparison, Diff, boolean)
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.