Class DefaultConflictDetector
- All Implemented Interfaces:
IConflictDetector
This default implementation of IConflictDetector
should detect most generic cases, but is not aimed
at detecting conflicts at "business" level. For example, adding two enum literals of the same value but
distinct IDs might be seen as a conflict... but that is not the "generic" case.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkConflict
(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called once for each difference in the comparison model.protected void
checkContainmentConflict
(Comparison comparison, ReferenceChange diff, Iterable<ReferenceChange> candidates) This will be called once for each ReferenceChange on containment references in the comparison model.protected void
checkContainmentConflict
(Comparison comparison, ReferenceChange diff, ReferenceChange candidate) For each couple of diffs on the same value in which one is a containment reference change, we will call this in order to check for possible conflicts.protected void
checkContainmentFeatureMapConflict
(Comparison comparison, FeatureMapChange diff, Iterable<FeatureMapChange> candidates) This will be called once for each FeatureMapChange on containment values in the comparison model.protected void
checkContainmentFeatureMapConflict
(Comparison comparison, FeatureMapChange diff, FeatureMapChange candidate) For each couple of diffs on the same value in which one is a containment feature map change, we will call this in order to check for possible conflicts.protected void
checkFeatureAddConflict
(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "ADD" and which is not a containment reference change.protected void
checkFeatureChangeConflict
(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "CHANGE".protected void
checkFeatureDeleteConflict
(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "DELETE" and which is not a containment reference change.protected void
checkFeatureMoveConflict
(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "CHANGE" or "MOVE".protected void
checkResourceAttachmentConflict
(Comparison comparison, ResourceAttachmentChange diff, Iterable<Diff> candidates) This will be called once for each ResourceAttachmentChange in the comparison model.protected void
checkResourceAttachmentConflict
(Comparison comparison, ResourceAttachmentChange diff, ReferenceChange candidate) This will be called fromcheckResourceAttachmentConflict(Comparison, ResourceAttachmentChange, Iterable)
for each ReferenceChange in the comparison model that is on the other side and that impacts the changed root.protected void
conflictOn
(Comparison comparison, Diff diff1, Diff diff2, ConflictKind kind) This will be called whenever we detect a new conflict in order to create (or update) the actual association.void
detect
(Comparison comparison, Monitor monitor) This is the entry point of the conflict detection process.protected MatchResource
getMatchResource
(Comparison comparison, Resource resource) Returns the MatchResource corresponding to the givenresource
.protected boolean
isMergeableText
(String left, String right, String origin) Specifies whether the given three versions of a textleft
,right
, andorigin
are mergeable with a line-based three-way merge.
-
Constructor Details
-
DefaultConflictDetector
public DefaultConflictDetector()
-
-
Method Details
-
detect
This is the entry point of the conflict detection process.It is expected to complete the input
comparison
by iterating over thedifferences
it contain, filling in all conflicts it can detect between those Diffs.- Specified by:
detect
in interfaceIConflictDetector
- Parameters:
comparison
- The comparison this engine is expected to complete.monitor
- The monitor to report progress or to check for cancellation- See Also:
-
checkConflict
This will be called once for each difference in the comparison model.- Parameters:
comparison
- The originating comparison of those diffs.diff
- Diff for which we are to try and determine conflicts.candidates
- An iterable over the Diffs that possible candidates for conflicts.
-
checkContainmentConflict
protected void checkContainmentConflict(Comparison comparison, ReferenceChange diff, Iterable<ReferenceChange> candidates) This will be called once for each ReferenceChange on containment references in the comparison model.- Parameters:
comparison
- The originating comparison of those diffs.diff
- The reference change for which we are to try and determine conflicts.candidates
- An iterable over the ReferenceChanges that are possible candidates for conflicts.
-
checkContainmentConflict
protected void checkContainmentConflict(Comparison comparison, ReferenceChange diff, ReferenceChange candidate) For each couple of diffs on the same value in which one is a containment reference change, we will call this in order to check for possible conflicts.Once here, we know that
diff
is a containment reference change, and we known thatdiff
andcandidate
are both pointing to the same value.candidate
can be a containment reference change, but that is not a given.- Parameters:
comparison
- The originating comparison of those diffs.diff
- Containment reference changes for which we need to check possible conflicts.candidate
- A reference change that point to the same value asdiff
.
-
checkContainmentFeatureMapConflict
protected void checkContainmentFeatureMapConflict(Comparison comparison, FeatureMapChange diff, Iterable<FeatureMapChange> candidates) This will be called once for each FeatureMapChange on containment values in the comparison model.- Parameters:
comparison
- The originating comparison of those diffs.diff
- The feature map change for which we are to try and determine conflicts.candidates
- An iterable over the FeatureMapChanges that are possible candidates for conflicts.- Since:
- 3.2
-
checkContainmentFeatureMapConflict
protected void checkContainmentFeatureMapConflict(Comparison comparison, FeatureMapChange diff, FeatureMapChange candidate) For each couple of diffs on the same value in which one is a containment feature map change, we will call this in order to check for possible conflicts.Once here, we know that
diff
is a containment feature map change, and we known thatdiff
andcandidate
are both pointing to the same value.candidate
can be a containment feature map change, but that is not a given.- Parameters:
comparison
- The originating comparison of those diffs.diff
- Containment feature map changes for which we need to check possible conflicts.candidate
- A feature map change that point to the same value asdiff
.- Since:
- 3.2
-
checkFeatureChangeConflict
protected void checkFeatureChangeConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "CHANGE".Those can only conflict with other CHANGE Diffs on the same reference.
- Parameters:
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite todiff
.
-
isMergeableText
Specifies whether the given three versions of a textleft
,right
, andorigin
are mergeable with a line-based three-way merge.- Parameters:
left
- The left version.right
- The right version.origin
- The original version.- Returns:
true
if they are mergeable, false otherwise.- Since:
- 3.2
-
checkFeatureMoveConflict
protected void checkFeatureMoveConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "CHANGE" or "MOVE".Those can only conflict with other Diffs of the same type on the same reference.
- Parameters:
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite todiff
.
-
checkFeatureDeleteConflict
protected void checkFeatureDeleteConflict(Comparison comparison, Diff diff, Iterable<Diff> candidates) This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "DELETE" and which is not a containment reference change.The only potential conflict for such a diff is a "MOVE" of that same value on the opposite side.
- Parameters:
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite todiff
.
-
checkFeatureAddConflict
This will be called fromcheckConflict(Comparison, Diff, Iterable)
in order to detect conflicts on a Diff that is of type "ADD" and which is not a containment reference change.These will conflict with Diffs on the other side on the same reference in the same container, of type ADD an on the same value.
- Parameters:
comparison
- The originating comparison of those diffs.diff
- The diff which we are to check for conflicts.candidates
- The list of candidates for a conflict. This list only contains Diff from the side opposite todiff
.
-
checkResourceAttachmentConflict
protected void checkResourceAttachmentConflict(Comparison comparison, ResourceAttachmentChange diff, Iterable<Diff> candidates) This will be called once for each ResourceAttachmentChange in the comparison model.- Parameters:
comparison
- The originating comparison of those diffs.diff
- The "root" difference for which we are to try and determine conflicts.candidates
- An iterable over the Diffs that are possible candidates for conflicts.
-
getMatchResource
Returns the MatchResource corresponding to the givenresource
.- Parameters:
comparison
- the comparison to search for a MatchResource.resource
- Resource for which we need a MatchResource.- Returns:
- The MatchResource corresponding to the given
resource
.
-
checkResourceAttachmentConflict
protected void checkResourceAttachmentConflict(Comparison comparison, ResourceAttachmentChange diff, ReferenceChange candidate) This will be called fromcheckResourceAttachmentConflict(Comparison, ResourceAttachmentChange, Iterable)
for each ReferenceChange in the comparison model that is on the other side and that impacts the changed root.- Parameters:
comparison
- The originating comparison of those diffs.diff
- Resource attachment change for which we need to check possible conflicts.candidate
- A reference change that point to the same value asdiff
.
-
conflictOn
This will be called whenever we detect a new conflict in order to create (or update) the actual association.- Parameters:
comparison
- The originating comparison of those diffs.diff1
- First of the two differences for which we detected a conflict.diff2
- Second of the two differences for which we detected a conflict.kind
- Kind of this conflict.
-