public abstract class AbstractMerger extends Object implements IMerger
IMerger
. This can be used as a base implementation to avoid
re-implementing the whole contract.IMerger.Registry, IMerger.RegistryImpl
Constructor and Description |
---|
AbstractMerger() |
Modifier and Type | Method and Description |
---|---|
protected void |
accept(Diff diff,
boolean rightToLeft)
Accept the given difference.
|
protected <E> void |
addAt(List<E> list,
E value,
int insertionIndex)
Adds the given
value into the given list at the given index . |
void |
copyLeftToRight(Diff target,
Monitor monitor)
Executes the copy from left to right.
|
void |
copyRightToLeft(Diff target,
Monitor monitor)
Executes the copy from right to left.
|
protected EObject |
createCopy(EObject referenceObject)
This will create a copy of the given EObject that can be used as the target of an addition (or the
reverting of a deletion).
|
int |
getRanking()
Returns the ranking of this merger.
|
IMerger.Registry |
getRegistry()
Get the registry.
|
protected boolean |
handleEquivalences(Diff diff,
boolean rightToLeft,
Monitor monitor)
Handles the equivalences of this difference.
|
protected void |
handleImpliedBy(Diff diff,
boolean rightToLeft,
Monitor monitor)
Mark as
merged all the implying differences recursively from the given
one. |
protected void |
handleImplies(Diff diff,
boolean rightToLeft,
Monitor monitor)
Mark as
merged all the implied differences recursively from the given
one. |
protected void |
mergeDiff(Diff diff,
boolean rightToLeft,
Monitor monitor)
This can be used by mergers to merge another (required, equivalent...) difference using the right
merger for that diff.
|
protected void |
mergeRequiredBy(Diff diff,
boolean rightToLeft,
Monitor monitor)
This will merge all
differences that require diff in the given
direction. |
protected void |
mergeRequires(Diff diff,
boolean rightToLeft,
Monitor monitor)
This will merge all
differences required by diff in the given
direction. |
protected void |
reject(Diff diff,
boolean rightToLeft)
Reject the given difference.
|
void |
setRanking(int r)
Set the ranking of this merger.
|
void |
setRegistry(IMerger.Registry registry)
Set the registry containing this merger.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isMergerFor
public int getRanking()
getRanking
in interface IMerger
IMerger.getRanking()
public void setRanking(int r)
setRanking
in interface IMerger
r
- The ranking.IMerger.setRanking(int)
public IMerger.Registry getRegistry()
getRegistry
in interface IMerger
IMerger.getRegistry()
public void setRegistry(IMerger.Registry registry)
setRegistry
in interface IMerger
registry
- The merger registry.IMerger.setRegistry(org.eclipse.emf.compare.merge.IMerger.Registry)
public void copyLeftToRight(Diff target, Monitor monitor)
copyLeftToRight
in interface IMerger
target
- The difference to handle.monitor
- Monitor.IMerger.copyLeftToRight(org.eclipse.emf.compare.Diff,
org.eclipse.emf.common.util.Monitor)
public void copyRightToLeft(Diff target, Monitor monitor)
copyRightToLeft
in interface IMerger
target
- The difference to handle.monitor
- Monitor.IMerger.copyRightToLeft(org.eclipse.emf.compare.Diff,
org.eclipse.emf.common.util.Monitor)
protected void accept(Diff diff, boolean rightToLeft)
diff
- the difference to mergerightToLeft
- the direction of the mergeprotected void reject(Diff diff, boolean rightToLeft)
diff
- the difference to mergerightToLeft
- the direction of the mergeprotected void mergeRequiredBy(Diff diff, boolean rightToLeft, Monitor monitor)
differences that require
diff
in the given
direction.diff
- We need to merge all differences that require this one (see Diff.getRequiredBy()
.rightToLeft
- If true
, apply
all differences that require
diff
. Otherwise, revert
them.monitor
- The monitor we should use to report progress.protected void handleImplies(Diff diff, boolean rightToLeft, Monitor monitor)
merged
all the implied differences recursively from the given
one.diff
- The difference from which the implications have to be marked.rightToLeft
- The direction of the merge.monitor
- Monitor.protected void handleImpliedBy(Diff diff, boolean rightToLeft, Monitor monitor)
merged
all the implying differences recursively from the given
one.diff
- The difference from which the implications have to be marked.rightToLeft
- The direction of the merge.monitor
- Monitor.protected void mergeRequires(Diff diff, boolean rightToLeft, Monitor monitor)
differences required by
diff
in the given
direction.protected void mergeDiff(Diff diff, boolean rightToLeft, Monitor monitor)
diff
- The diff we need to merge.rightToLeft
- Direction of that merge.monitor
- The monitor we should use to report progress.protected boolean handleEquivalences(Diff diff, boolean rightToLeft, Monitor monitor)
Note that in certain cases, we'll merge our opposite instead of merging this diff. Specifically, we'll do that for one-to-many eOpposites : we'll merge the 'many' side instead of the 'unique' one. This allows us not to worry about the order of the references on that 'many' side.
This is called before the merge of this
. In short, if this returns false
, we
won't carry on merging this
after returning.
diff
- The diff we are currently merging.rightToLeft
- Direction of the merge.monitor
- The monitor to use in order to report progress information.true
if the current difference should still be merged after handling its
equivalences, false
if it should be considered "already merged".protected EObject createCopy(EObject referenceObject)
The target will be self-contained and will have no reference towards any other EObject set (neither
containment nor "classic" references). All of its attributes' values will match the given
referenceObject
's.
referenceObject
- The EObject for which we'll create a copy.referenceObject
.EMFCompareCopier.copy(EObject)
protected <E> void addAt(List<E> list, E value, int insertionIndex)
value
into the given list
at the given index
. An index
under than zero or above the list's size will mean that the value should be appended at the end of the
list.E
- Type of objects contained in the list.list
- The list into which value
should be added.value
- The value we need to add to list
.insertionIndex
- The index at which value
should be inserted into list
. -1
if it
should be appended at the end of the list.
Copyright (c) 2006, 2014 Obeo and others. All rights reserved.