Class StrategyResourceMatcher
- java.lang.Object
-
- org.eclipse.emf.compare.match.resource.StrategyResourceMatcher
-
- All Implemented Interfaces:
IResourceMatcher
public class StrategyResourceMatcher extends Object implements IResourceMatcher
AStrategyResourceMatcherwill be used to match two or threeResources together; depending on whether we are doing a two or three way comparison.Do take note that the match engine expects ResourceMatchers to return matching resources as well as resources that do not match.
-
-
Field Summary
Fields Modifier and Type Field Description protected Comparator<Resource>resourceURIComparatorCompares resources according to the string representation of theirURIs.
-
Constructor Summary
Constructors Constructor Description StrategyResourceMatcher()Default constructor with two strategies:NameMatchingStrategy&RootIDMatchingStrategy.StrategyResourceMatcher(Collection<IResourceMatchingStrategy> strategies)Constructor that allows to give your ownIResourceMatchingStrategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static booleanatLeastTwo(boolean condition1, boolean condition2, boolean condition3)This will check that at least two of the three given booleans aretrue.Iterable<MatchResource>createMappings(Iterator<? extends Resource> leftResources, Iterator<? extends Resource> rightResources, Iterator<? extends Resource> originResources)This will be called by the engine in order to retrieve the mappings created by this matcher.protected static MatchResourcecreateMatchResource(Resource left, Resource right, Resource origin)Creates aMatchResourceinstance and sets all three resources of the mapping on it.protected IResourceMatchingStrategy[]getResourceMatchingStrategies()Returns the matching strategies that are to be used by this resource matcher.
-
-
-
Field Detail
-
resourceURIComparator
protected Comparator<Resource> resourceURIComparator
Compares resources according to the string representation of theirURIs.
-
-
Constructor Detail
-
StrategyResourceMatcher
public StrategyResourceMatcher()
Default constructor with two strategies:NameMatchingStrategy&RootIDMatchingStrategy.
-
StrategyResourceMatcher
public StrategyResourceMatcher(Collection<IResourceMatchingStrategy> strategies)
Constructor that allows to give your ownIResourceMatchingStrategy.- Parameters:
strategies- the strategies you want to use for the match step. A defensive copy of the provided strategies will be done.
-
-
Method Detail
-
createMappings
public Iterable<MatchResource> createMappings(Iterator<? extends Resource> leftResources, Iterator<? extends Resource> rightResources, Iterator<? extends Resource> originResources)
This will be called by the engine in order to retrieve the mappings created by this matcher.The returned mappings should include both "matching" resources and "not matching" resources (i.e. resources that are in either left or right ... but not in any of the two other lists).
- Specified by:
createMappingsin interfaceIResourceMatcher- Parameters:
leftResources- An iterator over the resources we found on the left side.rightResources- An iterator over the resources we found on the right side.originResources- An iterator over the resources that may be considered as common ancestors of the couples detected on the left and right sides.- Returns:
- The created resource mappings. Should include both matched and unmatched resources.
- See Also:
IResourceMatcher.createMappings(java.util.Iterator, java.util.Iterator, java.util.Iterator)
-
atLeastTwo
protected static boolean atLeastTwo(boolean condition1, boolean condition2, boolean condition3)This will check that at least two of the three given booleans aretrue.- Parameters:
condition1- First of the three booleans.condition2- Second of the three booleans.condition3- Third of the three booleans.- Returns:
trueif at least two of the three given booleans aretrue,falseotherwise.
-
getResourceMatchingStrategies
protected IResourceMatchingStrategy[] getResourceMatchingStrategies()
Returns the matching strategies that are to be used by this resource matcher.This default implementation will try two ways of matching the resources before giving up : resources have equal name, then resources have roots with equal identifiers.
Resource Matching Strategies are expected to map resources together, but not to detect resources that do not match.
- Returns:
- The resource matching strategies that should be used by this matcher.
-
createMatchResource
protected static MatchResource createMatchResource(Resource left, Resource right, Resource origin)
Creates aMatchResourceinstance 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.
-
-