public class ResourceAttachmentChangeMerger extends AbstractMerger
AbstractMerger
will be used to merge resource attachment changes.IMerger.Registry, IMerger.RegistryImpl
Constructor and Description |
---|
ResourceAttachmentChangeMerger() |
Modifier and Type | Method and Description |
---|---|
protected void |
accept(Diff diff,
boolean rightToLeft)
Accept the given difference.
|
protected void |
addInTarget(ResourceAttachmentChange diff,
boolean rightToLeft)
This will be called when we need to create an element in the target side.
|
protected URI |
computeTargetURI(Match match,
boolean rightToLeft)
Computes the URI of the "target" resource.
|
protected void |
deleteFormerResourceIfNecessary(Comparison comparison,
Resource oldResource,
boolean rightToLeft)
A move of an EObject to a different resource has just been made.
|
protected void |
deleteResource(Resource resource)
Delete the given resource.
|
protected <E> int |
findInsertionIndex(Comparison comparison,
List<E> source,
List<E> target,
E newElement)
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 Resource |
findOrCreateTargetResource(Match match,
boolean rightToLeft)
This will try and locate the "target" resource of this merge in the current comparison.
|
protected MatchResource |
getMatchResource(Comparison comparison,
Resource resource)
Returns the MatchResource corresponding to the given
resource . |
boolean |
isMergerFor(Diff target)
Check if the merger is a good candidate to merge the given difference.
|
protected void |
move(ResourceAttachmentChange diff,
boolean rightToLeft)
Handle moves of
ResourceAttachmentChange s. |
protected void |
reject(Diff diff,
boolean rightToLeft)
Reject the given difference.
|
protected void |
removeFromTarget(ResourceAttachmentChange diff,
boolean rightToLeft)
This will be called when we need to remove an element from the target side.
|
protected boolean |
resourceExistsInSource(MatchResource matchResource,
boolean rightToLeft)
Indicates whether a non-null resource exists in the source side for the given MatchResource.
|
addAt, copyLeftToRight, copyRightToLeft, createCopy, getDirectMergeDependencies, getDirectResultingMerges, getDirectResultingRejections, getRanking, getRegistry, handleEquivalences, handleImpliedBy, handleImplies, isAdd, mergeDiff, mergeRequiredBy, mergeRequires, setRanking, setRegistry
public boolean isMergerFor(Diff target)
target
- The given target difference.IMerger.isMergerFor(org.eclipse.emf.compare.Diff)
protected void accept(Diff diff, boolean rightToLeft)
accept
in class AbstractMerger
diff
- the difference to mergerightToLeft
- the direction of the mergeAbstractMerger.accept(org.eclipse.emf.compare.Diff, boolean)
protected void reject(Diff diff, boolean rightToLeft)
reject
in class AbstractMerger
diff
- the difference to mergerightToLeft
- the direction of the mergeAbstractMerger.reject(org.eclipse.emf.compare.Diff, boolean)
protected void move(ResourceAttachmentChange diff, boolean rightToLeft)
ResourceAttachmentChange
s.diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected void deleteFormerResourceIfNecessary(Comparison comparison, Resource oldResource, boolean rightToLeft)
comparison
- The comparisonoldResource
- The resource from where the EObject has been movedrightToLeft
- The direction of the changeprotected void deleteResource(Resource resource)
resource
- The resource to delete, must not be null.protected boolean resourceExistsInSource(MatchResource matchResource, boolean rightToLeft)
matchResource
- The matchResourcerightToLeft
- The direction of the mergeprotected void addInTarget(ResourceAttachmentChange 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. In other words, either :
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected Resource findOrCreateTargetResource(Match match, boolean rightToLeft)
match
- Match of the root which resource we need to find or create.rightToLeft
- Direction of the merge. This will tell us which side we are to look up for the target
resource.null
if no
valid target resource can be created.protected URI computeTargetURI(Match match, boolean rightToLeft)
match
- Match of the root for which we need a resource URI.rightToLeft
- Direction of the merge.null
if we cannot compute a
valid target URI.protected MatchResource getMatchResource(Comparison comparison, Resource resource)
resource
.comparison
- The current comparison.resource
- Resource for which we need a MatchResource.resource
.protected void removeFromTarget(ResourceAttachmentChange 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 difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected <E> int findInsertionIndex(Comparison comparison, List<E> source, List<E> target, E newElement)
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.
E
- Type of the sequences content.comparison
- This will be used in order to retrieve the Match for EObjects when comparing them.source
- The List from which one element has to be added to the target
list.target
- The List into which one element from source
has to be added.newElement
- The element from source
that needs to be added into target
.source
. -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.