Package org.eclipse.emf.compare.merge

## Class ComputeDiffsToMerge

- java.lang.Object
- - org.eclipse.emf.compare.merge.ComputeDiffsToMerge

    public class ComputeDiffsToMerge
    extends Object

This class computes the diffs to merge for a given diff in the correct order, taking into account the merger's indications about required and consequent diffs.

Required diffs
  These are the diffs that need to be merged (from a structural point of view) before a given diff for this diff to be mergeable by the merger.
Consequent diffs
  These are all the diffs that, for some reason, the merger considers necessary to merge along with a given diff, but which need not be merged before this diff for the merger to be able to merge it. This is used to define atomicity of merge operations: Each merger defines the set of diffs that must be merged together, and the engine makes surre all these diffs (required+consequent) are merged together or not at all in one 'transaction'.

Since:
  3.5

### Constructor Summary

Constructors
`ComputeDiffsToMerge​(boolean rightToLeft, IDiffRelationshipComputer relationshipComputer)` Constructor if there is no merge mode for this action.
`ComputeDiffsToMerge​(MergeMode mergeMode, boolean isLeftEditable, boolean isRightEditable, IDiffRelationshipComputer relationshipComputer)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `addDiff​(Diff diff)` Compute the ordered set of diffs for the given diff.
`protected void` `addDiff​(Diff diff, Set<Diff> consequences, Set<Diff> diffPath)` Recursively add the required diffs, then the diff itself, to the result.
`protected void` `addDiffs​(Collection<Diff> diffs, Set<Diff> diffPath)` Recursively add the given diffs to the result Set, starting by their requirements, then themselves, then their consequences, in the right order.
`ComputeDiffsToMerge` `failOnRealConflictUnless​(com.google.common.base.Predicate<? super Conflict> predicate)` Set the failOnConflict flag.
`Set<Diff>` `getAllDiffsToMerge​(Iterable<? extends Diff> diffs)` Compute the ordered set of diffs to merge for the given diffs.
`Set<Diff>` `getAllDiffsToMerge​(Diff diff)` Compute the ordered set of diffs to merge for the given diff.

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

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

### Constructor Detail

#### ComputeDiffsToMerge

    public ComputeDiffsToMerge​(MergeMode mergeMode,
                               boolean isLeftEditable,
                               boolean isRightEditable,
                               IDiffRelationshipComputer relationshipComputer)

Constructor.

Parameters:
  `mergeMode` - The kind of merging we're about to implement.
  `isLeftEditable` - Whether the left side of the comparison we're operating on is editable.
  `isRightEditable` - Whether the right side of the comparison we're operating on is editable.
  `relationshipComputer` - The relationship computer used to calculate dependencies and requirements of diffs.

#### ComputeDiffsToMerge

    public ComputeDiffsToMerge​(boolean rightToLeft,
                               IDiffRelationshipComputer relationshipComputer)

Constructor if there is no merge mode for this action.

Parameters:
  `rightToLeft` - Direction of the merge.
  `relationshipComputer` - The relationship computer used to calculate dependencies and requirements of diffs.

### Method Detail

#### failOnRealConflictUnless

    public ComputeDiffsToMerge failOnRealConflictUnless​(com.google.common.base.Predicate<? super Conflict> predicate)

Set the failOnConflict flag.

Parameters:
  `predicate` - Predicate that will be used to check whether an exception must be thrown when encountering a diff that's involved in a conflict. This predicate will be applied to the conflict, and if it returns `false` then an exception will be thrown.
Returns:
  This for a fluent API.

#### getAllDiffsToMerge

    public Set<Diff> getAllDiffsToMerge​(Iterable<? extends Diff> diffs)

Compute the ordered set of diffs to merge for the given diffs.

Parameters:
  `diffs` - The diffs to merge, along with its required diffs and its consequent diffs.
Returns:
  An ordered Set that contains all the diffs to merge, in the correct order based on required diffs and consequent diffs.

#### getAllDiffsToMerge

    public Set<Diff> getAllDiffsToMerge​(Diff diff)

Compute the ordered set of diffs to merge for the given diff.

Parameters:
  `diff` - The diff to merge, along with its required diffs and its consequent diffs.
Returns:
  An ordered Set that contains all the diffs to merge, in the correct order.

#### addDiff

    protected void addDiff​(Diff diff)

Compute the ordered set of diffs for the given diff.

Parameters:
  `diff` - The diff to merge

#### addDiffs

    protected void addDiffs​(Collection<Diff> diffs,
                            Set<Diff> diffPath)

Recursively add the given diffs to the result Set, starting by their requirements, then themselves, then their consequences, in the right order.

Parameters:
  `diffs` - The diffs to merge at the current step of the computation
  `diffPath` - The path that lead to a diff

#### addDiff

    protected void addDiff​(Diff diff,
                           Set<Diff> consequences,
                           Set<Diff> diffPath)

Recursively add the required diffs, then the diff itself, to the result. Also add the consequent diffs of all the required diffs and the provided one to the given set of consequences.

Parameters:
  `diff` - The diff to add
  `consequences` - The set of diffs that must be merged at the next step.
  `diffPath` - The path that lead to the diff to add