public class StrategyResourceMatcher extends Object implements IResourceMatcher
StrategyResourceMatcher
will be used to match two or three Resource
s 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.
Constructor and Description |
---|
StrategyResourceMatcher() |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
atLeastTwo(boolean condition1,
boolean condition2,
boolean condition3)
This will check that at least two of the three given booleans are
true . |
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 MatchResource |
createMatchResource(Resource left,
Resource right,
Resource origin)
Creates a
MatchResource instance 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.
|
public Iterable<MatchResource> createMappings(Iterator<? extends Resource> leftResources, Iterator<? extends Resource> rightResources, Iterator<? extends Resource> originResources)
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).
createMappings
in interface IResourceMatcher
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.IResourceMatcher.createMappings(java.util.Iterator,
java.util.Iterator, java.util.Iterator)
protected static boolean atLeastTwo(boolean condition1, boolean condition2, boolean condition3)
true
.condition1
- First of the three booleans.condition2
- Second of the three booleans.condition3
- Third of the three booleans.true
if at least two of the three given booleans are true
,
false
otherwise.protected IResourceMatchingStrategy[] getResourceMatchingStrategies()
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.
protected static MatchResource createMatchResource(Resource left, Resource right, Resource origin)
MatchResource
instance and sets all three resources of the mapping on it.left
- The left resource of this mapping.right
- The right resource of this mapping.origin
- The origin resource of this mapping.
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.