Package org.eclipse.emf.compare.merge

# Class DiffRelationshipComputer

java.lang.Object
org.eclipse.emf.compare.merge.DiffRelationshipComputer

All Implemented Interfaces:
  `IDiffRelationshipComputer`

Direct Known Subclasses:
  `CachingDiffRelationshipComputer`

public class DiffRelationshipComputer extends Object implements IDiffRelationshipComputer
A computer implementation to calculate the relationship of differences in EMF Compare.

Since:
  3.5
See Also:
  - `IMerger2`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected IMergeCriterion`
`criterion`
Merge criterion used to retrieve the correct merger.
`protected IMerger.Registry`
`registry`
Merger registry used to retrieve the correct merger.

## Constructor Summary

Constructors
Constructor
Description
`DiffRelationshipComputer(IMerger.Registry registry)`
Creates a new relationship computer.
`DiffRelationshipComputer(IMerger.Registry registry, IMergeCriterion criterion)`
Creates a new relationship computer.

## Method Summary

Modifier and Type
Method
Description
`Set<Diff>`
`getAllResultingMerges(Diff diff, boolean rightToLeft)`
Retrieves the set of all diffs related to the given `diff` when merging in the given direction.
`Set<Diff>`
`getAllResultingMerges(Diff diff, boolean rightToLeft, com.google.common.base.Predicate<? super Diff> filter)`
Retrieves the set of all diffs related to the given `diff` when merging in the given direction.
`Set<Diff>`
`getAllResultingRejections(Diff diff, boolean mergeRightToLeft)`
Retrieves the set of all diffs that will be rejected if the given `diff` is merged, either because of unresolveable conflicts or because of unreachable requirements.
`Set<Diff>`
`getAllResultingRejections(Diff diff, boolean mergeRightToLeft, com.google.common.base.Predicate<? super Diff> filter)`
Retrieves the set of all diffs that will be rejected if the given `diff` is merged, either because of unresolveable conflicts or because of unreachable requirements.
`Set<Diff>`
`getDirectMergeDependencies(Diff diff, boolean mergeRightToLeft)`
Retrieves the set of directly required diffs needed in order to merge the given `diff`.
`Set<Diff>`
`getDirectResultingMerges(Diff diff, boolean mergeRightToLeft)`
Returns all differences that will be merged because of our merging the given `diff`.
`Set<Diff>`
`getDirectResultingRejections(Diff diff, boolean mergeRightToLeft)`
Returns the set of all differences that need to be rejected if `diff` is merged in the given direction.
`IMergeCriterion`
`getMergeCriterion()`
Returns the merge criterion considered for calculating the diff relationships.
`IMerger2`
`getMerger(Diff diff)`
Returns the best-fitting merger for the given diff according to the `merger registry` and the `merge criterion`.
`IMerger.Registry`
`getMergerRegistry()`
Returns the merger registry used for calculating the diff relationships.
`protected IMerger.Registry2`
`getMergerRegistry2()`
Returns the `merger registry` as `IMerger.Registry2`, if possible.
`boolean`
`hasMerger(Diff diff)`
Indicates whether a best-fitting merger for the given diff is available.
`protected Set<Diff>`
`internalGetAllResultingMerges(Diff diff, boolean rightToLeft)`
Returns the set of all differences directly related to the given one, either as dependencies or as implications.
`void`
`setMergeCriterion(IMergeCriterion mergeCriterion)`
Sets the merge criterion considered for calculating the diff relationships.
`void`
`setMergerRegistry(IMerger.Registry mergerRegistry)`
Sets the merger registry used for calculating the diff relationships.

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

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

## Field Details

### registry

protected IMerger.Registry registry
Merger registry used to retrieve the correct merger.

### criterion

protected IMergeCriterion criterion
Merge criterion used to retrieve the correct merger.

## Constructor Details

### DiffRelationshipComputer

public DiffRelationshipComputer(IMerger.Registry registry)
Creates a new relationship computer.

Parameters:
  `registry` - merger registry

### DiffRelationshipComputer

public DiffRelationshipComputer(IMerger.Registry registry, IMergeCriterion criterion)
Creates a new relationship computer.

Parameters:
  `registry` - merger registry
  `criterion` - merge criterion used to get the merger from the registry, use `IMergeCriterion.NONE` if no special criterion should be set.

## Method Details

### getMergerRegistry

public IMerger.Registry getMergerRegistry()
Description copied from interface: `IDiffRelationshipComputer`
Returns the merger registry used for calculating the diff relationships.

Specified by:
  `getMergerRegistry` in interface `IDiffRelationshipComputer`
Returns:
  The merger registry.

### setMergerRegistry

public void setMergerRegistry(IMerger.Registry mergerRegistry)
Description copied from interface: `IDiffRelationshipComputer`
Sets the merger registry used for calculating the diff relationships.

Specified by:
  `setMergerRegistry` in interface `IDiffRelationshipComputer`
Parameters:
  `mergerRegistry` - The merger registry.

### getMergeCriterion

public IMergeCriterion getMergeCriterion()
Description copied from interface: `IDiffRelationshipComputer`
Returns the merge criterion considered for calculating the diff relationships.

Specified by:
  `getMergeCriterion` in interface `IDiffRelationshipComputer`
Returns:
  The merge criterion.

### setMergeCriterion

public void setMergeCriterion(IMergeCriterion mergeCriterion)
Description copied from interface: `IDiffRelationshipComputer`
Sets the merge criterion considered for calculating the diff relationships.

Specified by:
  `setMergeCriterion` in interface `IDiffRelationshipComputer`
Parameters:
  `mergeCriterion` - The merger criterion.

### getMergerRegistry2

protected IMerger.Registry2 getMergerRegistry2()
Returns the `merger registry` as `IMerger.Registry2`, if possible. If the merger registry is not an instance of `IMerger.Registry2`, null is returned.

Returns:
  `IMerger.Registry2` instance or null.

### getMerger

public IMerger2 getMerger(Diff diff)
Description copied from interface: `IDiffRelationshipComputer`
Returns the best-fitting merger for the given diff according to the `merger registry` and the `merge criterion`.

Specified by:
  `getMerger` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek the merger.
Returns:
  The best-fitting merger for the given diff or null if no merger fits.

### hasMerger

public boolean hasMerger(Diff diff)
Description copied from interface: `IDiffRelationshipComputer`
Indicates whether a best-fitting merger for the given diff is available.

Specified by:
  `hasMerger` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek the merger.
Returns:
  Returns true if a best-fitting merger is available, false otherwise.

### getDirectMergeDependencies

public Set<Diff> getDirectMergeDependencies(Diff diff, boolean mergeRightToLeft)
Description copied from interface: `IDiffRelationshipComputer`
Retrieves the set of directly required diffs needed in order to merge the given `diff`. This may includes the diff's requirements or any other diff that we need to merge before the given one.

Specified by:
  `getDirectMergeDependencies` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek the direct merge dependencies.
  `mergeRightToLeft` - The direction in which we're considering a merge.
Returns:
  A non-null set of direct merge dependencies.
See Also:
  - `IMerger2.getDirectMergeDependencies(Diff, boolean)`

### getDirectResultingMerges

public Set<Diff> getDirectResultingMerges(Diff diff, boolean mergeRightToLeft)
Description copied from interface: `IDiffRelationshipComputer`
Returns all differences that will be merged because of our merging the given `diff`. This may include the diff's implications, the diff's equivalences, the diff's refinements or any other diff that we need to merge together with the given diff.

Specified by:
  `getDirectResultingMerges` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek the direct merge dependencies.
  `mergeRightToLeft` - The direction in which we're considering a merge.
Returns:
  A non-null set of direct resulting merges.
See Also:
  - `IMerger2.getDirectResultingMerges(Diff, boolean)`

### getDirectResultingRejections

public Set<Diff> getDirectResultingRejections(Diff diff, boolean mergeRightToLeft)
Description copied from interface: `IDiffRelationshipComputer`
Returns the set of all differences that need to be rejected if `diff` is merged in the given direction.

Specified by:
  `getDirectResultingRejections` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek the direct resulting rejections.
  `mergeRightToLeft` - The direction in which we're considering a merge.
Returns:
  A non-null set of direct resulting rejections.
See Also:
  - `IDiffRelationshipComputer.getAllResultingRejections(Diff, boolean)`
  - `IMerger2.getDirectResultingRejections(Diff, boolean)`

### getAllResultingMerges

public Set<Diff> getAllResultingMerges(Diff diff, boolean rightToLeft)
Description copied from interface: `IDiffRelationshipComputer`
Retrieves the set of all diffs related to the given `diff` when merging in the given direction.

This is expected to return the set of all differences that will be need to merged along when a user wishes to merge `diff`, either because they are required by it or because they are implied by it one way or another.

Note that `diff` will be included in the returned set.

Also note that the resulting merges will contain the resulting rejections (diffs from the other side that will be rejected)

Specified by:
  `getAllResultingMerges` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek all related ones.
  `rightToLeft` - The direction in which we're considering a merge.
Returns:
  A non-null set of all diffs related to the given `diff` when merging in the given direction.

### getAllResultingMerges

public Set<Diff> getAllResultingMerges(Diff diff, boolean rightToLeft, com.google.common.base.Predicate<? super Diff> filter)
Description copied from interface: `IDiffRelationshipComputer`
Retrieves the set of all diffs related to the given `diff` when merging in the given direction.

This is expected to return the set of all differences that will be need to merged along when a user wishes to merge `diff`, either because they are required by it or because they are implied by it one way or another.

Note that `diff` will be included in the returned set.

Also note that the resulting merges will contain the resulting rejections (diffs from the other side that will be rejected)

Specified by:
  `getAllResultingMerges` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek all related ones.
  `rightToLeft` - The direction in which we're considering a merge.
  `filter` - The filter to control which diffs are visted when collecting the result.
Returns:
  A non-null set of all diffs related to the given `diff` when merging in the given direction.

### internalGetAllResultingMerges

protected Set<Diff> internalGetAllResultingMerges(Diff diff, boolean rightToLeft)
Returns the set of all differences directly related to the given one, either as dependencies or as implications.

Parameters:
  `diff` - The difference for which we seek all directly related others.
  `rightToLeft` - The direction in which we're considering a merge.
Returns:
  The set of all differences directly related to the given one.

### getAllResultingRejections

public Set<Diff> getAllResultingRejections(Diff diff, boolean mergeRightToLeft)
Description copied from interface: `IDiffRelationshipComputer`
Retrieves the set of all diffs that will be rejected if the given `diff` is merged, either because of unresolveable conflicts or because of unreachable requirements.

Specified by:
  `getAllResultingRejections` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek all opposite ones.
  `mergeRightToLeft` - The direction in which we're considering a merge.
Returns:
  A non-null set of all diffs that will be rejected if the given `diff` is merged in the given direction.

### getAllResultingRejections

public Set<Diff> getAllResultingRejections(Diff diff, boolean mergeRightToLeft, com.google.common.base.Predicate<? super Diff> filter)
Description copied from interface: `IDiffRelationshipComputer`
Retrieves the set of all diffs that will be rejected if the given `diff` is merged, either because of unresolveable conflicts or because of unreachable requirements.

Specified by:
  `getAllResultingRejections` in interface `IDiffRelationshipComputer`
Parameters:
  `diff` - The difference for which we seek all opposite ones.
  `mergeRightToLeft` - The direction in which we're considering a merge.
  `filter` - The filter to control which diffs are visted when collecting the result.
Returns:
  A non-null set of all diffs that will be rejected if the given `diff` is merged in the given direction.