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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected MatchResource
createMatchResource(Resource left, Resource right, Resource origin)
Creates aMatchResource
instance and sets all three resources of the mapping on it.protected Resource
findMatch(Resource reference, Iterable<Resource> candidates)
Deprecated.usefindMatches(Resource, Iterable)
instead.protected List<Resource>
findMatches(Resource reference, Iterable<Resource> candidates)
Returns the first two matches ofreference
incandidates
.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.
-
-
-
Method Detail
-
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 interfaceIResourceMatchingStrategy
- 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 ofreference
incandidates
. 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 matchreference
.- Returns:
- The first two matches of
reference
incandidates
. Empty list if none. - Since:
- 3.3
-
findMatch
@Deprecated protected Resource findMatch(Resource reference, Iterable<Resource> candidates)
Deprecated.usefindMatches(Resource, Iterable)
instead.Returns the first match ofreference
incandidates
. 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 matchreference
.- Returns:
- The first match of
reference
incandidates
.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 aMatchResource
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.
-
-