public abstract class AbstractMerger extends Object implements IMerger2, IMergeOptionAware
IMerger
. This can be used as a base implementation to avoid
re-implementing the whole contract.IMerger.Registry, IMerger.RegistryImpl
Modifier and Type | Field and Description |
---|---|
static String |
SUB_DIFF_AWARE_OPTION
The key of the merge option that allows to the mergers to consider sub-diffs of a diff as a whole.
|
Constructor and Description |
---|
AbstractMerger()
Default constructor.
|
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).
|
Set<Diff> |
getDirectMergeDependencies(Diff diff,
boolean mergeRightToLeft)
Retrieves the set of directly required diffs in order to merge the current one.
|
Set<Diff> |
getDirectResultingMerges(Diff target,
boolean mergeRightToLeft)
Returns all differences that will be merged because of our merging the given
target
difference. |
Set<Diff> |
getDirectResultingRejections(Diff target,
boolean mergeRightToLeft)
Returns the set of all differences that need to be rejected if
target is merged in the
given direction. |
Map<Object,Object> |
getMergeOptions()
Get the map of options that the merger will have to take into account.
|
int |
getRanking()
Returns the ranking of this merger.
|
IMerger.Registry |
getRegistry()
Get the registry.
|
protected boolean |
handleEquivalences(Diff diff,
boolean rightToLeft,
Monitor monitor)
Deprecated.
|
protected void |
handleImpliedBy(Diff diff,
boolean rightToLeft,
Monitor monitor)
Deprecated.
|
protected void |
handleImplies(Diff diff,
boolean rightToLeft,
Monitor monitor)
Deprecated.
|
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)
Deprecated.
|
protected void |
mergeRequires(Diff diff,
boolean rightToLeft,
Monitor monitor)
Deprecated.
|
protected void |
reject(Diff diff,
boolean rightToLeft)
Reject the given difference.
|
void |
setMergeOptions(Map<Object,Object> options)
Set the map of options that the merger will have to take into account.
|
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 static final String SUB_DIFF_AWARE_OPTION
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 Map<Object,Object> getMergeOptions()
getMergeOptions
in interface IMergeOptionAware
IMergeOptionAware.getMergeOptions()
public void setMergeOptions(Map<Object,Object> options)
setMergeOptions
in interface IMergeOptionAware
options
- the map of options.IMergeOptionAware.setMergeOptions(java.util.Map)
public Set<Diff> getDirectMergeDependencies(Diff diff, boolean mergeRightToLeft)
requirements
, its implying
diff
, or any other diff that we need to merge before the given one.getDirectMergeDependencies
in interface IMerger2
diff
- The diff which direct requirements we need.mergeRightToLeft
- The direction in which we're considering a merge.public Set<Diff> getDirectResultingMerges(Diff target, boolean mergeRightToLeft)
target
difference.getDirectResultingMerges
in interface IMerger2
target
- The difference we're considering merging.mergeRightToLeft
- The direction in which we're considering a merge.target
.public Set<Diff> getDirectResultingRejections(Diff target, boolean mergeRightToLeft)
target
is merged in the
given direction.getDirectResultingRejections
in interface IMerger2
target
- The difference we're considering merging.mergeRightToLeft
- The direction in which we're considering a merge.target
.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 merge@Deprecated protected 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.@Deprecated 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.@Deprecated 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.@Deprecated 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.@Deprecated protected boolean handleEquivalences(Diff diff, boolean rightToLeft, Monitor monitor)
Note that in certain cases, we'll merge our opposite instead of merging this diff. This is done to
avoid merge orders where merging differences of kind DifferenceKind.REMOVE
or
DifferenceKind.CHANGE
(resulting in an unset) first can lead to information loss. Additionally
in case of one-to-many eOpposites this allows us not to worry about the order of the references on the
'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, 2015 Obeo and others. All rights reserved.