Class DefaultMatchEngine

java.lang.Object
org.eclipse.emf.compare.match.DefaultMatchEngine
All Implemented Interfaces:
IMatchEngine

public class DefaultMatchEngine extends Object implements IMatchEngine
The Match engine orchestrates the matching process : it takes an scope as input, iterates over its left, right and origin roots and delegates to IResourceMatchers and IEObjectMatchers in order to create the result Comparison model for this scope.
  • Field Details

    • DEFAULT_EOBJECT_URI_CACHE_MAX_SIZE

      public static final int DEFAULT_EOBJECT_URI_CACHE_MAX_SIZE
      Default max size of the EObject's URI loading cache.
      See Also:
  • Constructor Details

    • DefaultMatchEngine

      public DefaultMatchEngine(IEObjectMatcher matcher, IComparisonFactory comparisonFactory)
      This default engine delegates the pairing of EObjects to an IEObjectMatcher.
      Parameters:
      matcher - The matcher that will be in charge of pairing EObjects together for this comparison process.
      comparisonFactory - factory that will be use to instantiate Comparison as return by match() methods.
      Since:
      3.0
    • DefaultMatchEngine

      public DefaultMatchEngine(IEObjectMatcher eObjectMatcher, IResourceMatcher resourceMatcher, IComparisonFactory comparisonFactory)
      This default engine delegates the pairing of EObjects to an IEObjectMatcher.
      Parameters:
      eObjectMatcher - The matcher that will be in charge of pairing EObjects together for this comparison process.
      resourceMatcher - The matcher that will be in charge of pairing EObjects together for this comparison process.
      comparisonFactory - factory that will be use to instantiate Comparison as return by match() methods.
      Since:
      3.2
  • Method Details

    • match

      public Comparison match(IComparisonScope scope, Monitor monitor)
      This is the entry point of a Comparison process. It is expected to use the provided scope in order to determine all objects that need to be matched.

      The returned Comparison should include both matched an unmatched objects. It is not the match engine's responsibility to determine differences between objects, only to match them together.

      Specified by:
      match in interface IMatchEngine
      Parameters:
      scope - The comparison scope that should be used by this engine to determine the objects to match.
      monitor - The monitor to report progress or to check for cancellation
      Returns:
      An initialized Comparison model with all matches determined.
      See Also:
    • match

      protected void match(Comparison comparison, IComparisonScope scope, Notifier left, Notifier right, Notifier origin, Monitor monitor)
      This methods will delegate to the proper "match(T, T, T)" implementation according to the types of left, right and origin.
      Parameters:
      comparison - The comparison to which will be added detected matches.
      scope - The comparison scope that should be used by this engine to determine the objects to match.
      left - The left Notifier.
      right - The right Notifier.
      origin - The common ancestor of left and right. Can be null.
      monitor - The monitor to report progress or to check for cancellation
    • match

      protected void match(Comparison comparison, IComparisonScope scope, ResourceSet left, ResourceSet right, ResourceSet origin, Monitor monitor)
      This will be used to match the given ResourceSets. This default implementation will query the comparison scope for these resource sets children, then delegate to an IResourceMatcher to determine the resource mappings.
      Parameters:
      comparison - The comparison to which will be added detected matches.
      scope - The comparison scope that should be used by this engine to determine the objects to match.
      left - The left ResourceSet.
      right - The right ResourceSet.
      origin - The common ancestor of left and right. Can be null.
      monitor - The monitor to report progress or to check for cancellation
    • match

      protected void match(Comparison comparison, IComparisonScope scope, Resource left, Resource right, Resource origin, Monitor monitor)
      This will only query the scope for the given Resources' children, then delegate to an IEObjectMatcher to determine the EObject matches.

      We expect at least two of the given resources not to be null.

      Parameters:
      comparison - The comparison to which will be added detected matches.
      scope - The comparison scope that should be used by this engine to determine the objects to match.
      left - The left Resource. Can be null.
      right - The right Resource. Can be null.
      origin - The common ancestor of left and right. Can be null.
      monitor - The monitor to report progress or to check for cancellation
    • match

      protected void match(Comparison comparison, IComparisonScope scope, EObject left, EObject right, EObject origin, Monitor monitor)
      This will query the scope for the given EObjects' children, then delegate to an IEObjectMatcher to compute the Matches.

      We expect at least the left and right EObjects not to be null.

      Parameters:
      comparison - The comparison to which will be added detected matches.
      scope - The comparison scope that should be used by this engine to determine the objects to match.
      left - The left EObject.
      right - The right EObject.
      origin - The common ancestor of left and right.
      monitor - The monitor to report progress or to check for cancellation.
    • createResourceMatcher

      @Deprecated protected IResourceMatcher createResourceMatcher()
      Deprecated.
      use DefaultMatchEngine constructor with StrategyResourceMatcher parameter instead.
      This will be used to create the resource matcher that will be used by this match engine.
      Returns:
      An IResourceMatcher that can be used to retrieve the MatchResources for this comparison.
    • getResourceMatcher

      protected final IResourceMatcher getResourceMatcher()
      Returns the Resource matcher associated with this match engine.
      Returns:
      The Resource matcher associated with this match engine.
    • getEObjectMatcher

      protected final IEObjectMatcher getEObjectMatcher()
      Returns the EObject matcher associated with this match engine.
      Returns:
      The EObject matcher associated with this match engine.
    • create

      public static IMatchEngine create(UseIdentifiers useIDs)
      Helper creator method that instantiate a DefaultMatchEngine that will use identifiers as specified by the given useIDs enumeration.
      Parameters:
      useIDs - the kinds of matcher to use.
      Returns:
      a new DefaultMatchEngine instance.
    • create

      public static IMatchEngine create(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry)
      Helper creator method that instantiate a DefaultMatchEngine that will use identifiers as specified by the given useIDs enumeration.
      Parameters:
      useIDs - the kinds of matcher to use.
      weightProviderRegistry - the match engine needs a WeightProvider in case of this match engine do not use identifiers.
      Returns:
      a new DefaultMatchEngine instance.
    • create

      public static IMatchEngine create(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry, Collection<IResourceMatchingStrategy> strategies)
      Helper creator method that instantiate a DefaultMatchEngine that will use identifiers as specified by the given useIDs enumeration.
      Parameters:
      useIDs - the kinds of matcher to use.
      weightProviderRegistry - the match engine needs a WeightProvider in case of this match engine do not use identifiers.
      strategies - the matching strategies you want to use for the match step.
      Returns:
      a new DefaultMatchEngine instance.
    • create

      public static IMatchEngine create(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry, EqualityHelperExtensionProvider.Descriptor.Registry equalityHelperExtensionProviderRegistry, Collection<IResourceMatchingStrategy> strategies)
      Helper creator method that instantiate a DefaultMatchEngine that will use identifiers as specified by the given useIDs enumeration.
      Parameters:
      useIDs - the kinds of matcher to use.
      weightProviderRegistry - the match engine needs a WeightProvider in case of this match engine do not use identifiers.
      equalityHelperExtensionProviderRegistry - the match engine may need a Equality Helper Extension
      strategies - the matching strategies you want to use for the match step.
      Returns:
      a new DefaultMatchEngine instance.
    • createDefaultEObjectMatcher

      public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs)
      Creates and configures an IEObjectMatcher with the strategy given by useIDs. The cache will be used to cache some expensive computation (should better a LoadingCache).
      Parameters:
      useIDs - which strategy the return IEObjectMatcher must follow.
      Returns:
      a new IEObjectMatcher.
    • createDefaultEObjectMatcher

      public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry)
      Creates and configures an IEObjectMatcher with the strategy given by useIDs. The cache will be used to cache some expensive computation (should better a LoadingCache).
      Parameters:
      useIDs - which strategy the return IEObjectMatcher must follow.
      weightProviderRegistry - the match engine needs a WeightProvider in case of this match engine do not use identifiers.
      Returns:
      a new IEObjectMatcher.
    • createDefaultEObjectMatcher

      public static IEObjectMatcher createDefaultEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry, EqualityHelperExtensionProvider.Descriptor.Registry equalityHelperExtensionProviderRegistry)
      Creates and configures an IEObjectMatcher with the strategy given by useIDs. The cache will be used to cache some expensive computation (should better a LoadingCache).
      Parameters:
      useIDs - which strategy the return IEObjectMatcher must follow.
      weightProviderRegistry - the match engine needs a WeightProvider in case of this match engine do not use identifiers.
      equalityHelperExtensionProviderRegistry - the match engine may need a Equality helper extension.
      Returns:
      a new IEObjectMatcher.