Class StrategyResourceMatcher

java.lang.Object
org.eclipse.emf.compare.match.resource.StrategyResourceMatcher
All Implemented Interfaces:
IResourceMatcher

public class StrategyResourceMatcher extends Object implements 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 Details

    • resourceURIComparator

      protected Comparator<Resource> resourceURIComparator
      Compares resources according to the string representation of their URIs.
  • Constructor Details

  • 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:
      createMappings in interface IResourceMatcher
      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 are true.
      Parameters:
      condition1 - First of the three booleans.
      condition2 - Second of the three booleans.
      condition3 - Third of the three booleans.
      Returns:
      true if at least two of the three given booleans are true, false otherwise.
    • 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 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.