org.eclipse.emf.compare.internal.conflict

## Class AbstractConflictSearch<T extends Diff>

- java.lang.Object
- - org.eclipse.emf.compare.internal.conflict.AbstractConflictSearch<T>

Type Parameters:
  `T` - The type of diff for which conflict are researched

Direct Known Subclasses:
  AttributeChangeConflictSearch.Add, AttributeChangeConflictSearch.Change, AttributeChangeConflictSearch.Delete, AttributeChangeConflictSearch.Move, ContainmentRefChangeConflictSearch.Add, ContainmentRefChangeConflictSearch.Change, ContainmentRefChangeConflictSearch.Delete, ContainmentRefChangeConflictSearch.Move, FeatureMapChangeConflictSearch.Add, FeatureMapChangeConflictSearch.Change, FeatureMapChangeConflictSearch.Delete, FeatureMapChangeConflictSearch.Move, NonContainmentRefChangeConflictSearch.Add, NonContainmentRefChangeConflictSearch.Change, NonContainmentRefChangeConflictSearch.Delete, NonContainmentRefChangeConflictSearch.Move, ResourceAttachmentChangeConflictSearch.Add, ResourceAttachmentChangeConflictSearch.Change, ResourceAttachmentChangeConflictSearch.Delete, ResourceAttachmentChangeConflictSearch.Move

    public abstract class AbstractConflictSearch<T extends Diff>
    extends Object

Class in charge of finding conflicting diffs for a given diff of type T.

### Field Summary

Fields
`protected Comparison` `comparison` The comparison that contains diff.
`protected T` `diff` The difference, never `null`.
`protected ComparisonIndex` `index` The index of the comparison.
`protected Monitor` `monitor` The monitor to report progress to.

### Constructor Summary

Constructors
Constructor and Description
`AbstractConflictSearch(T diff, ComparisonIndex index, Monitor monitor)` Constructor.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected boolean` `areMergeableStringAttributeChanges(Diff diff1, Diff diff2)` Specifies whether the two given diffs, `diff1` and `diff2`, are both `attribute changes` of String attributes and can be merged with a line-based three-way merge.
`protected void` `conflict(Diff other, ConflictKind kind)` This will be called whenever we detect a new conflict in order to create (or update) the actual association.
`abstract void` `detectConflicts()` Detect conflicts with `diff` in its comparison.
`protected String` `getChangedValue(AttributeChange attributeChange)` Returns the changed attribute value denoted by the given `diff`.
`protected EList<Diff>` `getDiffsInSameMatch()` Get the diffs in the same `Match` as diff.
`protected FeatureFilter` `getFeatureFilter(Comparison comp)` Returns the feature filter attached to the given comparison if any.
`protected MatchResource` `getMatchResource(Resource resource)` Returns the MatchResource corresponding to the given `resource`.
`protected EObject` `getRelatedModelElement(ResourceAttachmentChange rac)` Provide the model element the given diff applies to.
`protected EObject` `getValue(ResourceAttachmentChange rac)` Provide the non-null model element the given diff applies to.
`protected Predicate<? super Match>` `isContainmentDelete()` This predicate will be `true` for any Match which represents a containment deletion.
`protected boolean` `isFeatureMapChange(Diff toCheck)` Specifies whether the given `diff` is a `FeatureMapChange`.
`protected boolean` `isFeatureMapChangeOrMergeableStringAttributeChange(Diff diff1, Diff diff2)` Specifies whether the given `diff1` and `diff2` are either `feature map changes` or mergeable `attribute changes` of String attributes.
`protected boolean` `isMergeable(AttributeChange diff1, AttributeChange diff2)` Specifies whether the two given attribute changes, `diff1` and `diff2`, can be merged with a line-based three-way merge.
`protected boolean` `isMergeableText(String left, String right, String origin)` Specifies whether the given three versions of a text `left`, `right`, and `origin` are mergeable with a line-based three-way merge.
`protected boolean` `isStringAttributeChange(Diff toCheck)` Specifies whether the given `diff` is a `AttributeChange` of a String attribute.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### diff

    protected final T extends Diff diff

The difference, never `null`.

#### comparison

    protected final Comparison comparison

The comparison that contains diff.

#### index

    protected final ComparisonIndex index

The index of the comparison.

#### monitor

    protected final Monitor monitor

The monitor to report progress to.

### Constructor Detail

#### AbstractConflictSearch

    public AbstractConflictSearch(T diff,
                                  ComparisonIndex index,
                                  Monitor monitor)

Constructor.

Parameters:
  `diff` - The diff to search conflicts with, must not be `null` and have a non-null match that belongs to a non-null comparison. It must also have a non-null `DifferenceKind` and `DifferenceSource`.
  `index` - Comparison index, must not be null
  `monitor` - the monitor to report progress to, must not be null

### Method Detail

#### detectConflicts

    public abstract void detectConflicts()

Detect conflicts with `diff` in its comparison. This will add or update conflicts in `diff`'s comparison.

#### getDiffsInSameMatch

    protected EList<Diff> getDiffsInSameMatch()

Get the diffs in the same `Match` as diff.

Returns:
  A never-null EList of differences in the same `Match` as diff, including diff.

#### isFeatureMapChangeOrMergeableStringAttributeChange

    protected boolean isFeatureMapChangeOrMergeableStringAttributeChange(Diff diff1,
                                                                         Diff diff2)

Specifies whether the given `diff1` and `diff2` are either `feature map changes` or mergeable `attribute changes` of String attributes.

Parameters:
  `diff1` - One of the diffs to check.
  `diff2` - The other diff to check.
Returns:
  `true` if it is a `FeatureMapChange` or a mergeable `AttributeChange`, `false` otherwise.

#### isFeatureMapChange

    protected boolean isFeatureMapChange(Diff toCheck)

Specifies whether the given `diff` is a `FeatureMapChange`.

Parameters:
  `toCheck` - The diff to check.
Returns:
  `true` if it is a `FeatureMapChange`, `false` otherwise.

#### areMergeableStringAttributeChanges

    protected boolean areMergeableStringAttributeChanges(Diff diff1,
                                                         Diff diff2)

Specifies whether the two given diffs, `diff1` and `diff2`, are both `attribute changes` of String attributes and can be merged with a line-based three-way merge.

Parameters:
  `diff1` - One of the diffs to check.
  `diff2` - The other diff to check.
Returns:
  `true` if the diffs are mergeable changes of a string attribute, `false` otherwise.
See Also:
  `ThreeWayTextDiff`

#### isStringAttributeChange

    protected boolean isStringAttributeChange(Diff toCheck)

Specifies whether the given `diff` is a `AttributeChange` of a String attribute.

Parameters:
  `toCheck` - The diff to check.
Returns:
  `true` if it is a `AttributeChange` of a String attribute, `false` otherwise.

#### isMergeable

    protected boolean isMergeable(AttributeChange diff1,
                                  AttributeChange diff2)

Specifies whether the two given attribute changes, `diff1` and `diff2`, can be merged with a line-based three-way merge.

Parameters:
  `diff1` - One of the attribute changes to check.
  `diff2` - The other attribute change to check.
Returns:
  `true` if the attribute changes are mergeable, `false` otherwise.
See Also:
  `ThreeWayTextDiff`

#### isMergeableText

    protected boolean isMergeableText(String left,
                                      String right,
                                      String origin)

Specifies whether the given three versions of a text `left`, `right`, and `origin` 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

#### getChangedValue

    protected String getChangedValue(AttributeChange attributeChange)

Returns the changed attribute value denoted by the given `diff`.

Parameters:
  `attributeChange` - The attribute change for which the changed value is requested.
Returns:
  The changed attribute value.

#### conflict

    protected void conflict(Diff other,
                            ConflictKind kind)

This will be called whenever we detect a new conflict in order to create (or update) the actual association.

Parameters:
  `other` - Second of the two differences for which we detected a conflict.
  `kind` - Kind of this conflict.

#### getMatchResource

    protected MatchResource getMatchResource(Resource resource)

Returns the MatchResource corresponding to the given `resource`.

Parameters:
  `resource` - Resource for which we need a MatchResource.
Returns:
  The MatchResource corresponding to the given `resource`.

#### getRelatedModelElement

    protected EObject getRelatedModelElement(ResourceAttachmentChange rac)

Provide the model element the given diff applies to.

Parameters:
  `rac` - The change
Returns:
  The model element of the given diff, or null if it cannot be found.

#### getValue

    protected EObject getValue(ResourceAttachmentChange rac)

Provide the non-null model element the given diff applies to.

Parameters:
  `rac` - The change
Returns:
  The model element of the given diff, cannot be null.

#### isContainmentDelete

    protected Predicate<? super Match> isContainmentDelete()

This predicate will be `true` for any Match which represents a containment deletion.

Returns:
  A Predicate that will be met by containment deletions.

#### getFeatureFilter

    protected FeatureFilter getFeatureFilter(Comparison comp)

Returns the feature filter attached to the given comparison if any.

Parameters:
  `comp` - The comparison.
Returns:
  The feature filter attached to the given comparison if any.