public abstract class AbstractMerger extends Object implements IMerger2
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.
|
Set<Diff> |
getResultingMerges(Diff diff,
boolean mergeLeftToRight,
Set<Diff> knownImplications)
Retrieves the set of all diffs related to the given
diff when merging in the given
direction. |
Set<Diff> |
getResultingRejections(Diff diff,
boolean mergeLeftToRight,
Set<Diff> knownRejections)
Retrieves the set of all diffs that will be rejected if the given
diff is merged, either
because of unresolveable conflicts or because of unreachable requirements. |
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 boolean |
isAdd(ReferenceChange diff,
boolean rightToLeft)
Specifies whether the given
diff will add a value in the target model for the current merging. |
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 Set<Diff> getResultingMerges(Diff diff, boolean mergeLeftToRight, Set<Diff> knownImplications)
diff
when merging in the given
direction.
This is expected to return the set of all differences that will be merged along when a user wishes to
merge diff
, either because they are related or because they are equivalent one way or
another.
Note that as far as the merged is concerned a given diff is considered to be implying itself.
diff
will thus be included in the returned set.
getResultingMerges
in interface IMerger2
diff
- The difference for which we seek all related ones.mergeLeftToRight
- The direction in which we're considering a merge.knownImplications
- The set of Diffs already known as being implied by our starting point. Since there may be
implication cycles, this can be used to break free. Callees are not supposed to add the new
implications they find within this set.diff
when merging in the given
direction.public Set<Diff> getResultingRejections(Diff diff, boolean mergeLeftToRight, Set<Diff> knownRejections)
diff
is merged, either
because of unresolveable conflicts or because of unreachable requirements.getResultingRejections
in interface IMerger2
diff
- The difference for which we seek all opposite ones.mergeLeftToRight
- The direction in which we're considering a merge.knownRejections
- The set of Diffs already known as being rejected by our starting point. Since there may be
rejection cycles, this can be used to break free. Callees are not supposed to add the new
rejections they find within this set.diff
is merged in the
given direction.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 boolean isAdd(ReferenceChange diff, boolean rightToLeft)
diff
will add a value in the target model for the current merging.
To check whether the diff
is an addition, we have to check the direction of the merge,
specified in rightToLeft
and the source of the diff
. Therefore, this
method delegates to isLeftAddOrRightDelete(ReferenceChange)
and
isLeftDeleteOrRightAdd(ReferenceChange)
.
diff
- The difference to check.rightToLeft
- Direction of the merge.true
if diff
will add a value with this merge, false
otherwise.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.