Class StrategyResourceMatcher
java.lang.Object
org.eclipse.emf.compare.match.resource.StrategyResourceMatcher
- All Implemented Interfaces:
IResourceMatcher
A
StrategyResourceMatcher will be used to match two or three Resources 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
FieldsModifier and TypeFieldDescriptionprotected Comparator<Resource>Compares resources according to the string representation of theirURIs. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with two strategies:NameMatchingStrategy&RootIDMatchingStrategy.StrategyResourceMatcher(Collection<IResourceMatchingStrategy> strategies) Constructor that allows to give your ownIResourceMatchingStrategy. -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanatLeastTwo(boolean condition1, boolean condition2, boolean condition3) This will check that at least two of the three given booleans aretrue.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[]Returns the matching strategies that are to be used by this resource matcher.
-
Field Details
-
resourceURIComparator
Compares resources according to the string representation of theirURIs.
-
-
Constructor Details
-
StrategyResourceMatcher
public StrategyResourceMatcher()Default constructor with two strategies:NameMatchingStrategy&RootIDMatchingStrategy. -
StrategyResourceMatcher
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 Details
-
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:
-
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
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
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.
-