Package org.eclipse.emf.compare.merge
Class ResourceAttachmentChangeMerger
java.lang.Object
org.eclipse.emf.compare.merge.AbstractMerger
org.eclipse.emf.compare.merge.ResourceAttachmentChangeMerger
- All Implemented Interfaces:
IMergeCriterionAware
,IMergeOptionAware
,IMerger
,IMerger2
- Direct Known Subclasses:
AdditiveResourceAttachmentChangeMerger
This specific implementation of
AbstractMerger
will be used to merge resource attachment changes.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.emf.compare.merge.IMerger
IMerger.Registry, IMerger.Registry2, IMerger.RegistryImpl
-
Field Summary
Fields inherited from class org.eclipse.emf.compare.merge.AbstractMerger
mergeOptions, SUB_DIFF_AWARE_OPTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
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.boolean
apply
(IMergeCriterion criterion) Default implementation of apply for mergers that extends this class.protected URI
computeTargetURI
(Match match, boolean rightToLeft) Computes the URI of the "target" resource.protected void
deleteFormerResourceIfNecessary
(Comparison comparison, Resource oldResource, boolean rightToLeft) Deprecated.protected void
deleteResource
(Resource resource) Deprecated.Not used anymore, it's not the responsibility of the ResourceAttachmentChangeMerger to delete resources.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 givenresource
.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 ofResourceAttachmentChange
s.protected boolean
mustDelete
(Resource resource, ResourceAttachmentChange diff, boolean rightToLeft) Deprecated.Don't use this method.protected void
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.Methods inherited from class org.eclipse.emf.compare.merge.AbstractMerger
addAt, copyDiff, copyLeftToRight, copyRightToLeft, createCopy, getDirectMergeDependencies, getDirectResultingMerges, getDirectResultingRejections, getImpliedMerges, getLogicallyResultingMerges, getMergeOptions, getMergerDelegate, getMergerDelegate, getRanking, getRegistry, isAccepting, isAdd, isInTerminalState, isSet, isUnset, mergeDiff, setMergeOptions, setRanking, setRegistry
-
Constructor Details
-
ResourceAttachmentChangeMerger
public ResourceAttachmentChangeMerger()
-
-
Method Details
-
isMergerFor
Check if the merger is a good candidate to merge the given difference.- Parameters:
target
- The given target difference.- Returns:
- True if it is the good candidate, false otherwise.
- See Also:
-
apply
Description copied from class:AbstractMerger
Default implementation of apply for mergers that extends this class. Will acceptnull
or AdditiveMergeCriterion.INSTANCE.- Specified by:
apply
in interfaceIMergeCriterionAware
- Overrides:
apply
in classAbstractMerger
- Parameters:
criterion
- The merge criterion- Returns:
true
if the given criterion is null or is AdditiveMergeCriterion.INSTANCE.
-
accept
Accept the given difference. This may be overridden by clients.- Overrides:
accept
in classAbstractMerger
- Parameters:
diff
- the difference to mergerightToLeft
- the direction of the merge- See Also:
-
reject
Reject the given difference. This may be overridden by clients.- Overrides:
reject
in classAbstractMerger
- Parameters:
diff
- the difference to mergerightToLeft
- the direction of the merge- See Also:
-
move
Handle moves ofResourceAttachmentChange
s.- Parameters:
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.
-
deleteFormerResourceIfNecessary
@Deprecated protected void deleteFormerResourceIfNecessary(Comparison comparison, Resource oldResource, boolean rightToLeft) Deprecated.UseResourceAttachmentChangeMerger#deleteFormerResourceIfNecessary(ResourceAttachmentChange, Resource, boolean)
instead.A move of an EObject to a different resource has just been made. Do whatever post-treatment is needed. The default implementation deletes the former resource if it's no longer supposed to be here.- Parameters:
comparison
- The comparisonoldResource
- The resource from where the EObject has been movedrightToLeft
- The direction of the change
-
mustDelete
@Deprecated protected boolean mustDelete(Resource resource, ResourceAttachmentChange diff, boolean rightToLeft) Deprecated.Don't use this method.Indicate whether the given resource must be marked for deletion or not. Can be overridden in sub-classes if necessary.- Parameters:
resource
- The resource candidate for deletiondiff
- The ResourceAttachmentChange that's just been mergedrightToLeft
- The direction of the merge- Returns:
true
if the given resource must be deleted.
-
deleteResource
Deprecated.Not used anymore, it's not the responsibility of the ResourceAttachmentChangeMerger to delete resources. This is now achieved by installing aResourceChangeAdapter
on comparisons.This method doesn't do anything now. The deletion of resources that need to be deleted is performed elsewhere.- Parameters:
resource
- The resource to delete
-
addInTarget
This will be called when we need to create an element in the target side.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 :
- We are copying from right to left and
- we are copying an addition to the right side (we need to create the same root in the left), or
- we are copying a deletion from the left side (we need to revert the deletion).
- We are copying from left to right and
- we are copying a deletion from the right side (we need to revert the deletion), or
- we are copying an addition to the left side (we need to create the same root in the right).
- Parameters:
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.
- We are copying from right to left and
-
findOrCreateTargetResource
This will try and locate the "target" resource of this merge in the current comparison. If we can't locate it, we assume that it needs to be created as we are in the process of adding a new element to it.- Parameters:
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.- Returns:
- The resource we could find in the current comparison if any. Otherwise, we'll return either a
newly created resource that can serve as a target of this merge, or
null
if no valid target resource can be created.
-
computeTargetURI
Computes the URI of the "target" resource. Will be used if we need to create or "find" it.- Parameters:
match
- Match of the root for which we need a resource URI.rightToLeft
- Direction of the merge.- Returns:
- The URI that is to be used for our target resource.
null
if we cannot compute a valid target URI.
-
getMatchResource
Returns the MatchResource corresponding to the givenresource
.- Parameters:
comparison
- The current comparison.resource
- Resource for which we need a MatchResource.- Returns:
- The MatchResource corresponding to the given
resource
.
-
removeFromTarget
This will be called when we need to remove an element from the target side.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 :
- Copying from right to left and either
- we are copying a deletion from the right side (we need to remove the same root from the left) or,
- we are copying an addition to the left side (we need to revert the addition).
- Copying from left to right and either
- we are copying an addition to the right side (we need to revert the addition), or.
- we are copying a deletion from the left side (we need to remove the same root from the right).
- Parameters:
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.
- Copying from right to left and either
-
findInsertionIndex
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. SeeDiffUtil.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.- Type Parameters:
E
- Type of the sequences content.- Parameters:
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 thetarget
list.target
- The List into which one element fromsource
has to be added.newElement
- The element fromsource
that needs to be added intotarget
.- Returns:
- The index at which the new value should be inserted into the 'target' list, as inferred from
its position in
source
.-1
if the value should be inserted at the end of its target list. - See Also:
-
ResourceAttachmentChangeMerger#deleteFormerResourceIfNecessary(ResourceAttachmentChange, Resource, boolean)
instead.