Package org.eclipse.emf.compare.match.resource

# Class RootIDMatchingStrategy

java.lang.Object
org.eclipse.emf.compare.match.resource.RootIDMatchingStrategy

All Implemented Interfaces:
  `IResourceMatchingStrategy`

public class RootIDMatchingStrategy extends Object implements IResourceMatchingStrategy
This implementation of a matching strategy checks for the IDs of the resources' roots, and consider that resources match if the identifiers of their roots do.

## Constructor Summary

Constructors
Constructor
Description
`RootIDMatchingStrategy()`

## Method Summary

Modifier and Type
Method
Description
`protected MatchResource`
`createMatchResource(Resource left, Resource right, Resource origin)`
Creates a `MatchResource` instance and sets all three resources of the mapping on it.
`protected Resource`
`findMatch(Resource reference, Iterable<Resource> candidates)`
Deprecated.
use `findMatches(Resource, Iterable)` instead.
`protected List<Resource>`
`findMatches(Resource reference, Iterable<Resource> candidates)`
Returns the first two matches of `reference` in `candidates`.
`protected Set<String>`
`getResourceIdentifiers(Resource resource)`
Retrieves the set of identifiers for the given resource's root.
`List<MatchResource>`
`matchResources(Iterable<? extends Resource> left, Iterable<? extends Resource> right, Iterable<? extends Resource> origin)`
Matches the given resources according to the IDs found in their roots.

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

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

## Constructor Details

### RootIDMatchingStrategy

public RootIDMatchingStrategy()

## Method Details

### matchResources

public List<MatchResource> matchResources(Iterable<? extends Resource> left, Iterable<? extends Resource> right, Iterable<? extends Resource> origin)
Matches the given resources according to the IDs found in their roots.

When the root IDs of two resources intersect, they are considered as matching. This strategy will only return unique matches between all resources.

Specified by:
  `matchResources` in interface `IResourceMatchingStrategy`
Parameters:
  `left` - Resources we are to match in the left.
  `right` - Resources we are to match in the right.
  `origin` - Resources we are to match in the origin.
Returns:
  The list of unique mappings this strategy managed to determine.

### findMatches

protected List<Resource> findMatches(Resource reference, Iterable<Resource> candidates)
Returns the first two matches of `reference` in `candidates`. This implementation will consider two Resources to be "matches" if their roots have IDs, and these IDs intersect.

Subclasses may return more than two elements if considered useful.

Parameters:
  `reference` - The reference resource.
  `candidates` - The list of potential candidates that may match `reference`.
Returns:
  The first two matches of `reference` in `candidates`. Empty list if none.
Since:
  3.3

### findMatch

@Deprecated protected Resource findMatch(Resource reference, Iterable<Resource> candidates)
Deprecated.
use `findMatches(Resource, Iterable)` instead.
Returns the first match of `reference` in `candidates`. This implementation will consider two Resources to be "matches" if their roots have IDs, and these IDs are the same.

Parameters:
  `reference` - The reference resource.
  `candidates` - The list of potential candidates that may match `reference`.
Returns:
  The first match of `reference` in `candidates`. `null` if none.

### getResourceIdentifiers

protected Set<String> getResourceIdentifiers(Resource resource)
Retrieves the set of identifiers for the given resource's root.

Parameters:
  `resource` - The resource for which we need the identifiers.
Returns:
  The identifiers (both XMI:ID and eAttribute ID) of the resource's roots, if any. May be empty if the resource has no roots or if they have no ID.

### createMatchResource

protected MatchResource createMatchResource(Resource left, Resource right, Resource origin)
Creates a `MatchResource` instance and sets all three resources of the mapping on it.

Parameters:
  `left` - The left resource of this mapping.
  `right` - The right resource of this mapping.
  `origin` - The origin resource of this mapping.
Returns:
  The create mapping.