Upgrade to EMF Compare 3.0
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
index 48aa6e5..4912d78 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/CDOCompareUtil.java
@@ -27,48 +27,24 @@
 import org.eclipse.emf.cdo.util.CDOUtil;
 import org.eclipse.emf.cdo.view.CDOView;
 
-import org.eclipse.emf.common.notify.Adapter;
 import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.BasicMonitor;
-import org.eclipse.emf.common.util.Monitor;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.compare.CompareFactory;
 import org.eclipse.emf.compare.Comparison;
-import org.eclipse.emf.compare.EMFCompareConfiguration;
+import org.eclipse.emf.compare.EMFCompare;
 import org.eclipse.emf.compare.Match;
-import org.eclipse.emf.compare.MatchResource;
-import org.eclipse.emf.compare.conflict.DefaultConflictDetector;
-import org.eclipse.emf.compare.conflict.IConflictDetector;
-import org.eclipse.emf.compare.diff.DefaultDiffEngine;
-import org.eclipse.emf.compare.diff.DiffBuilder;
-import org.eclipse.emf.compare.diff.IDiffEngine;
-import org.eclipse.emf.compare.diff.IDiffProcessor;
-import org.eclipse.emf.compare.equi.DefaultEquiEngine;
-import org.eclipse.emf.compare.equi.IEquiEngine;
-import org.eclipse.emf.compare.extension.EMFCompareExtensionRegistry;
-import org.eclipse.emf.compare.extension.IPostProcessor;
-import org.eclipse.emf.compare.extension.PostProcessorDescriptor;
-import org.eclipse.emf.compare.match.IMatchEngine;
+import org.eclipse.emf.compare.match.DefaultComparisonFactory;
+import org.eclipse.emf.compare.match.DefaultEqualityHelperFactory;
+import org.eclipse.emf.compare.match.DefaultMatchEngine;
+import org.eclipse.emf.compare.match.IComparisonFactory;
 import org.eclipse.emf.compare.match.eobject.IEObjectMatcher;
 import org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher;
-import org.eclipse.emf.compare.match.resource.IResourceMatcher;
-import org.eclipse.emf.compare.match.resource.StrategyResourceMatcher;
-import org.eclipse.emf.compare.req.DefaultReqEngine;
-import org.eclipse.emf.compare.req.IReqEngine;
 import org.eclipse.emf.compare.scope.IComparisonScope;
-import org.eclipse.emf.compare.utils.EqualityHelper;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.emf.spi.cdo.InternalCDOSession;
 import org.eclipse.emf.spi.cdo.InternalCDOSession.MergeData;
 
 import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -231,432 +207,435 @@
     return createComparison(scope, objectsToDeactivateOnClose);
   }
 
-  private static EMFCompare createComparator(IComparisonScope scope)
+  private static EMFCompare createComparator()
   {
     Function<EObject, String> idFunction = new CDOIDFunction();
-    IEObjectMatcher matcher = new IdentifierEObjectMatcher.Builder().idFunction(idFunction).build();
+    IEObjectMatcher matcher = new IdentifierEObjectMatcher(idFunction);
 
-    EMFCompare comparator = EMFCompare.newComparator(scope);
-    comparator.setEObjectMatcher(matcher);
+    IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
+    EMFCompare comparator = EMFCompare.builder().setMatchEngine(new DefaultMatchEngine(matcher, comparisonFactory))
+        .build();
     return comparator;
   }
 
   private static CDOComparison createComparison(IComparisonScope scope, Set<Object> objectsToDeactivateOnClose)
   {
-    EMFCompare comparator = createComparator(scope);
-    Comparison comparison = comparator.compare();
+    EMFCompare comparator = createComparator();
+    Comparison comparison = comparator.compare(scope);
     return new CDOComparison(scope, comparison, objectsToDeactivateOnClose);
   }
 
-  /**
-   * FIXME: To be removed when bug 390849 is resolved.
-   *
-   * @author Eike Stepper
-   */
-  private static final class EMFCompare
-  {
-    private IEObjectMatcher eObjectMatcher;
-
-    private Monitor progressMonitor;
-
-    private final IComparisonScope scope;
-
-    private EMFCompare(IComparisonScope scope)
-    {
-      com.google.common.base.Preconditions.checkNotNull(scope);
-      this.scope = scope;
-    }
-
-    public static EMFCompare newComparator(IComparisonScope scope)
-    {
-      return new EMFCompare(scope);
-    }
-
-    private static Comparison compare(IComparisonScope scope, EMFCompareConfiguration configuration,
-        IEObjectMatcher matcher)
-    {
-      final IMatchEngine matchEngine = new DefaultMatchEngine(matcher)
-      {
-        /**
-         * FIXME: CDO-specific.
-         */
-        @Override
-        protected void match(Notifier left, Notifier right, Notifier origin)
-        {
-          match((EObject)left, (EObject)right, (EObject)origin);
-        }
-      };
-
-      Comparison comparison = matchEngine.match(scope, configuration);
-
-      IPostProcessor postProcessor = getPostProcessor(scope);
-      if (postProcessor != null)
-      {
-        postProcessor.postMatch(comparison);
-      }
-
-      final IDiffProcessor diffBuilder = new DiffBuilder();
-
-      final IDiffEngine diffEngine = new DefaultDiffEngine(diffBuilder);
-      diffEngine.diff(comparison);
-
-      if (postProcessor != null)
-      {
-        postProcessor.postDiff(comparison);
-      }
-
-      final IReqEngine reqEngine = new DefaultReqEngine();
-      reqEngine.computeRequirements(comparison);
-
-      if (postProcessor != null)
-      {
-        postProcessor.postRequirements(comparison);
-      }
-
-      final IEquiEngine equiEngine = new DefaultEquiEngine();
-      equiEngine.computeEquivalences(comparison);
-
-      if (postProcessor != null)
-      {
-        postProcessor.postEquivalences(comparison);
-      }
-
-      if (comparison.isThreeWay())
-      {
-        final IConflictDetector conflictDetector = new DefaultConflictDetector();
-        conflictDetector.detect(comparison);
-
-        if (postProcessor != null)
-        {
-          postProcessor.postConflicts(comparison);
-        }
-      }
-
-      return comparison;
-    }
-
-    private static IPostProcessor getPostProcessor(IComparisonScope scope)
-    {
-      IPostProcessor postProcessor = null;
-      final Iterator<PostProcessorDescriptor> postProcessorIterator = EMFCompareExtensionRegistry
-          .getRegisteredPostProcessors().iterator();
-      while (postProcessorIterator.hasNext() && postProcessor == null)
-      {
-        final PostProcessorDescriptor descriptor = postProcessorIterator.next();
-        if (descriptor.getNsURI() != null && descriptor.getNsURI().trim().length() != 0)
-        {
-          final Iterator<String> nsUris = scope.getNsURIs().iterator();
-          while (nsUris.hasNext() && postProcessor == null)
-          {
-            if (nsUris.next().matches(descriptor.getNsURI()))
-            {
-              postProcessor = descriptor.getPostProcessor();
-            }
-          }
-        }
-
-        if (descriptor.getResourceURI() != null && descriptor.getResourceURI().trim().length() != 0)
-        {
-          final Iterator<String> resourceUris = scope.getResourceURIs().iterator();
-          while (resourceUris.hasNext() && postProcessor == null)
-          {
-            if (resourceUris.next().matches(descriptor.getResourceURI()))
-            {
-              postProcessor = descriptor.getPostProcessor();
-            }
-          }
-        }
-      }
-      return postProcessor;
-    }
-
-    public Comparison compare()
-    {
-      final Monitor monitor;
-      if (progressMonitor != null)
-      {
-        monitor = progressMonitor;
-      }
-      else
-      {
-        monitor = new BasicMonitor();
-      }
-
-      EqualityHelper helper = new EqualityHelper();
-      EMFCompareConfiguration configuration = new EMFCompareConfiguration(monitor, helper);
-      IEObjectMatcher matcher = createMatcher(helper);
-
-      return compare(scope, configuration, matcher);
-    }
-
-    public EMFCompare setEObjectMatcher(IEObjectMatcher matcher)
-    {
-      if (matcher != null)
-      {
-        eObjectMatcher = matcher;
-      }
-      return this;
-    }
-
-    private IEObjectMatcher createMatcher(EqualityHelper helper)
-    {
-      return eObjectMatcher;
-    }
-
-    /**
-     * FIXME: Remove this when bug 390846 has been resolved.
-     *
-     * @author Eike Stepper
-     */
-    private static class DefaultMatchEngine implements IMatchEngine
-    {
-      private Comparison comparison;
-
-      private IComparisonScope comparisonScope;
-
-      private IEObjectMatcher eObjectMatcher;
-
-      public DefaultMatchEngine(IEObjectMatcher matcher)
-      {
-        com.google.common.base.Preconditions.checkNotNull(matcher);
-        eObjectMatcher = matcher;
-      }
-
-      public Comparison match(IComparisonScope scope, EMFCompareConfiguration configuration)
-      {
-        comparisonScope = scope;
-        associate(getComparison(), configuration);
-
-        final Notifier left = getScope().getLeft();
-        final Notifier right = getScope().getRight();
-        final Notifier origin = getScope().getOrigin();
-
-        getComparison().setThreeWay(origin != null);
-
-        match(left, right, origin);
-
-        return getComparison();
-      }
-
-      protected void match(final Notifier left, final Notifier right, final Notifier origin)
-      {
-        if (left instanceof ResourceSet || right instanceof ResourceSet)
-        {
-          match((ResourceSet)left, (ResourceSet)right, (ResourceSet)origin);
-        }
-        else if (left instanceof Resource || right instanceof Resource)
-        {
-          match((Resource)left, (Resource)right, (Resource)origin);
-        }
-        else if (left instanceof EObject || right instanceof EObject)
-        {
-          match((EObject)left, (EObject)right, (EObject)origin);
-        }
-      }
-
-      protected void match(ResourceSet left, ResourceSet right, ResourceSet origin)
-      {
-        final Iterator<? extends Resource> leftChildren = getScope().getCoveredResources(left);
-        final Iterator<? extends Resource> rightChildren = getScope().getCoveredResources(right);
-        final Iterator<? extends Resource> originChildren;
-        if (origin != null)
-        {
-          originChildren = getScope().getCoveredResources(origin);
-        }
-        else
-        {
-          originChildren = Iterators.emptyIterator();
-        }
-
-        final IResourceMatcher resourceMatcher = getResourceMatcher();
-        final Iterable<MatchResource> mappings = resourceMatcher.createMappings(leftChildren, rightChildren,
-            originChildren);
-
-        Iterator<? extends EObject> leftEObjects = Iterators.emptyIterator();
-        Iterator<? extends EObject> rightEObjects = Iterators.emptyIterator();
-        Iterator<? extends EObject> originEObjects = Iterators.emptyIterator();
-
-        for (MatchResource mapping : mappings)
-        {
-          getComparison().getMatchedResources().add(mapping);
-
-          final Resource leftRes = mapping.getLeft();
-          final Resource rightRes = mapping.getRight();
-          final Resource originRes = mapping.getOrigin();
-
-          if (leftRes != null)
-          {
-            leftEObjects = Iterators.concat(leftEObjects, getScope().getCoveredEObjects(leftRes));
-          }
-
-          if (rightRes != null)
-          {
-            rightEObjects = Iterators.concat(rightEObjects, getScope().getCoveredEObjects(rightRes));
-          }
-
-          if (originRes != null)
-          {
-            originEObjects = Iterators.concat(originEObjects, getScope().getCoveredEObjects(originRes));
-          }
-        }
-
-        final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
-        Iterables.addAll(getComparison().getMatches(), matches);
-      }
-
-      protected void match(Resource left, Resource right, Resource origin)
-      {
-        // Our "roots" are Resources. Consider them matched
-        final MatchResource match = CompareFactory.eINSTANCE.createMatchResource();
-
-        match.setLeft(left);
-        match.setRight(right);
-        match.setOrigin(origin);
-
-        if (left != null)
-        {
-          URI uri = left.getURI();
-          if (uri != null)
-          {
-            match.setLeftURI(uri.toString());
-          }
-        }
-
-        if (right != null)
-        {
-          URI uri = right.getURI();
-          if (uri != null)
-          {
-            match.setRightURI(uri.toString());
-          }
-        }
-
-        if (origin != null)
-        {
-          URI uri = origin.getURI();
-          if (uri != null)
-          {
-            match.setOriginURI(uri.toString());
-          }
-        }
-
-        getComparison().getMatchedResources().add(match);
-
-        // We need at least two resources to match them
-        if (atLeastTwo(left == null, right == null, origin == null))
-        {
-          return;
-        }
-
-        final Iterator<? extends EObject> leftEObjects;
-        if (left != null)
-        {
-          leftEObjects = getScope().getCoveredEObjects(left);
-        }
-        else
-        {
-          leftEObjects = Iterators.emptyIterator();
-        }
-        final Iterator<? extends EObject> rightEObjects;
-        if (right != null)
-        {
-          rightEObjects = getScope().getCoveredEObjects(right);
-        }
-        else
-        {
-          rightEObjects = Iterators.emptyIterator();
-        }
-        final Iterator<? extends EObject> originEObjects;
-        if (origin != null)
-        {
-          originEObjects = getScope().getCoveredEObjects(origin);
-        }
-        else
-        {
-          originEObjects = Iterators.emptyIterator();
-        }
-
-        final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
-
-        Iterables.addAll(getComparison().getMatches(), matches);
-      }
-
-      protected void match(EObject left, EObject right, EObject origin)
-      {
-        if (left == null || right == null)
-        {
-          throw new IllegalArgumentException();
-        }
-
-        final Iterator<? extends EObject> leftEObjects = Iterators.concat(Iterators.singletonIterator(left), getScope()
-            .getChildren(left));
-        final Iterator<? extends EObject> rightEObjects = Iterators.concat(Iterators.singletonIterator(right),
-            getScope().getChildren(right));
-        final Iterator<? extends EObject> originEObjects;
-        if (origin != null)
-        {
-          originEObjects = Iterators.concat(Iterators.singletonIterator(origin), getScope().getChildren(origin));
-        }
-        else
-        {
-          originEObjects = Iterators.emptyIterator();
-        }
-
-        final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
-
-        Iterables.addAll(getComparison().getMatches(), matches);
-      }
-
-      protected IResourceMatcher getResourceMatcher()
-      {
-        return new StrategyResourceMatcher();
-      }
-
-      protected IEObjectMatcher getEObjectMatcher()
-      {
-        return eObjectMatcher;
-      }
-
-      protected Comparison getComparison()
-      {
-        if (comparison == null)
-        {
-          comparison = CompareFactory.eINSTANCE.createComparison();
-        }
-        return comparison;
-      }
-
-      protected IComparisonScope getScope()
-      {
-        return comparisonScope;
-      }
-
-      protected static boolean atLeastTwo(boolean condition1, boolean condition2, boolean condition3)
-      {
-        // CHECKSTYLE:OFF This expression is alone in its method, and documented.
-        return condition1 && (condition2 || condition3) || condition2 && condition3;
-        // CHECKSTYLE:ON
-      }
-
-      private static void associate(Comparison comparison, EMFCompareConfiguration configuration)
-      {
-        Iterator<Adapter> eAdapters = comparison.eAdapters().iterator();
-        while (eAdapters.hasNext())
-        {
-          Adapter eAdapter = eAdapters.next();
-          if (eAdapter.isAdapterForType(EMFCompareConfiguration.class))
-          {
-            eAdapters.remove();
-            if (eAdapter instanceof Adapter.Internal)
-            {
-              ((Adapter.Internal)eAdapter).unsetTarget(comparison);
-            }
-          }
-        }
-
-        comparison.eAdapters().add(configuration);
-        configuration.setTarget(comparison);
-      }
-    }
-  }
+  // /**
+  // * FIXME: To be removed when bug 390849 is resolved.
+  // *
+  // * @author Eike Stepper
+  // */
+  // private static final class _EMFCompare
+  // {
+  // private IEObjectMatcher eObjectMatcher;
+  //
+  // private Monitor progressMonitor;
+  //
+  // private final IComparisonScope scope;
+  //
+  // private _EMFCompare(IComparisonScope scope)
+  // {
+  // com.google.common.base.Preconditions.checkNotNull(scope);
+  // this.scope = scope;
+  // }
+  //
+  // public static EMFCompare newComparator(IComparisonScope scope)
+  // {
+  // return null; // Just temporary fix to make the Kepler train run again!
+  //
+  // // return new EMFCompare(scope);
+  // }
+  //
+  // private static Comparison compare(IComparisonScope scope, EMFCompareConfiguration configuration,
+  // IEObjectMatcher matcher)
+  // {
+  // final IMatchEngine matchEngine = new DefaultMatchEngine(matcher)
+  // {
+  // /**
+  // * FIXME: CDO-specific.
+  // */
+  // @Override
+  // protected void match(Notifier left, Notifier right, Notifier origin)
+  // {
+  // match((EObject)left, (EObject)right, (EObject)origin);
+  // }
+  // };
+  //
+  // Comparison comparison = matchEngine.match(scope, configuration);
+  //
+  // IPostProcessor postProcessor = getPostProcessor(scope);
+  // if (postProcessor != null)
+  // {
+  // postProcessor.postMatch(comparison);
+  // }
+  //
+  // final IDiffProcessor diffBuilder = new DiffBuilder();
+  //
+  // final IDiffEngine diffEngine = new DefaultDiffEngine(diffBuilder);
+  // diffEngine.diff(comparison);
+  //
+  // if (postProcessor != null)
+  // {
+  // postProcessor.postDiff(comparison);
+  // }
+  //
+  // final IReqEngine reqEngine = new DefaultReqEngine();
+  // reqEngine.computeRequirements(comparison);
+  //
+  // if (postProcessor != null)
+  // {
+  // postProcessor.postRequirements(comparison);
+  // }
+  //
+  // final IEquiEngine equiEngine = new DefaultEquiEngine();
+  // equiEngine.computeEquivalences(comparison);
+  //
+  // if (postProcessor != null)
+  // {
+  // postProcessor.postEquivalences(comparison);
+  // }
+  //
+  // if (comparison.isThreeWay())
+  // {
+  // final IConflictDetector conflictDetector = new DefaultConflictDetector();
+  // conflictDetector.detect(comparison);
+  //
+  // if (postProcessor != null)
+  // {
+  // postProcessor.postConflicts(comparison);
+  // }
+  // }
+  //
+  // return comparison;
+  // }
+  //
+  // private static IPostProcessor getPostProcessor(IComparisonScope scope)
+  // {
+  // IPostProcessor postProcessor = null;
+  // final Iterator<PostProcessorDescriptor> postProcessorIterator = EMFCompareExtensionRegistry
+  // .getRegisteredPostProcessors().iterator();
+  // while (postProcessorIterator.hasNext() && postProcessor == null)
+  // {
+  // final PostProcessorDescriptor descriptor = postProcessorIterator.next();
+  // if (descriptor.getNsURI() != null && descriptor.getNsURI().trim().length() != 0)
+  // {
+  // final Iterator<String> nsUris = scope.getNsURIs().iterator();
+  // while (nsUris.hasNext() && postProcessor == null)
+  // {
+  // if (nsUris.next().matches(descriptor.getNsURI()))
+  // {
+  // postProcessor = descriptor.getPostProcessor();
+  // }
+  // }
+  // }
+  //
+  // if (descriptor.getResourceURI() != null && descriptor.getResourceURI().trim().length() != 0)
+  // {
+  // final Iterator<String> resourceUris = scope.getResourceURIs().iterator();
+  // while (resourceUris.hasNext() && postProcessor == null)
+  // {
+  // if (resourceUris.next().matches(descriptor.getResourceURI()))
+  // {
+  // postProcessor = descriptor.getPostProcessor();
+  // }
+  // }
+  // }
+  // }
+  // return postProcessor;
+  // }
+  //
+  // public Comparison compare()
+  // {
+  // final Monitor monitor;
+  // if (progressMonitor != null)
+  // {
+  // monitor = progressMonitor;
+  // }
+  // else
+  // {
+  // monitor = new BasicMonitor();
+  // }
+  //
+  // EqualityHelper helper = new EqualityHelper();
+  // EMFCompareConfiguration configuration = new EMFCompareConfiguration(monitor, helper);
+  // IEObjectMatcher matcher = createMatcher(helper);
+  //
+  // return compare(scope, configuration, matcher);
+  // }
+  //
+  // public EMFCompare setEObjectMatcher(IEObjectMatcher matcher)
+  // {
+  // if (matcher != null)
+  // {
+  // eObjectMatcher = matcher;
+  // }
+  // return this;
+  // }
+  //
+  // private IEObjectMatcher createMatcher(EqualityHelper helper)
+  // {
+  // return eObjectMatcher;
+  // }
+  //
+  // /**
+  // * FIXME: Remove this when bug 390846 has been resolved.
+  // *
+  // * @author Eike Stepper
+  // */
+  // private static class DefaultMatchEngine implements IMatchEngine
+  // {
+  // private Comparison comparison;
+  //
+  // private IComparisonScope comparisonScope;
+  //
+  // private IEObjectMatcher eObjectMatcher;
+  //
+  // public DefaultMatchEngine(IEObjectMatcher matcher)
+  // {
+  // com.google.common.base.Preconditions.checkNotNull(matcher);
+  // eObjectMatcher = matcher;
+  // }
+  //
+  // public Comparison match(IComparisonScope scope, EMFCompareConfiguration configuration)
+  // {
+  // comparisonScope = scope;
+  // associate(getComparison(), configuration);
+  //
+  // final Notifier left = getScope().getLeft();
+  // final Notifier right = getScope().getRight();
+  // final Notifier origin = getScope().getOrigin();
+  //
+  // getComparison().setThreeWay(origin != null);
+  //
+  // match(left, right, origin);
+  //
+  // return getComparison();
+  // }
+  //
+  // protected void match(final Notifier left, final Notifier right, final Notifier origin)
+  // {
+  // if (left instanceof ResourceSet || right instanceof ResourceSet)
+  // {
+  // match((ResourceSet)left, (ResourceSet)right, (ResourceSet)origin);
+  // }
+  // else if (left instanceof Resource || right instanceof Resource)
+  // {
+  // match((Resource)left, (Resource)right, (Resource)origin);
+  // }
+  // else if (left instanceof EObject || right instanceof EObject)
+  // {
+  // match((EObject)left, (EObject)right, (EObject)origin);
+  // }
+  // }
+  //
+  // protected void match(ResourceSet left, ResourceSet right, ResourceSet origin)
+  // {
+  // final Iterator<? extends Resource> leftChildren = getScope().getCoveredResources(left);
+  // final Iterator<? extends Resource> rightChildren = getScope().getCoveredResources(right);
+  // final Iterator<? extends Resource> originChildren;
+  // if (origin != null)
+  // {
+  // originChildren = getScope().getCoveredResources(origin);
+  // }
+  // else
+  // {
+  // originChildren = Iterators.emptyIterator();
+  // }
+  //
+  // final IResourceMatcher resourceMatcher = getResourceMatcher();
+  // final Iterable<MatchResource> mappings = resourceMatcher.createMappings(leftChildren, rightChildren,
+  // originChildren);
+  //
+  // Iterator<? extends EObject> leftEObjects = Iterators.emptyIterator();
+  // Iterator<? extends EObject> rightEObjects = Iterators.emptyIterator();
+  // Iterator<? extends EObject> originEObjects = Iterators.emptyIterator();
+  //
+  // for (MatchResource mapping : mappings)
+  // {
+  // getComparison().getMatchedResources().add(mapping);
+  //
+  // final Resource leftRes = mapping.getLeft();
+  // final Resource rightRes = mapping.getRight();
+  // final Resource originRes = mapping.getOrigin();
+  //
+  // if (leftRes != null)
+  // {
+  // leftEObjects = Iterators.concat(leftEObjects, getScope().getCoveredEObjects(leftRes));
+  // }
+  //
+  // if (rightRes != null)
+  // {
+  // rightEObjects = Iterators.concat(rightEObjects, getScope().getCoveredEObjects(rightRes));
+  // }
+  //
+  // if (originRes != null)
+  // {
+  // originEObjects = Iterators.concat(originEObjects, getScope().getCoveredEObjects(originRes));
+  // }
+  // }
+  //
+  // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
+  // Iterables.addAll(getComparison().getMatches(), matches);
+  // }
+  //
+  // protected void match(Resource left, Resource right, Resource origin)
+  // {
+  // // Our "roots" are Resources. Consider them matched
+  // final MatchResource match = CompareFactory.eINSTANCE.createMatchResource();
+  //
+  // match.setLeft(left);
+  // match.setRight(right);
+  // match.setOrigin(origin);
+  //
+  // if (left != null)
+  // {
+  // URI uri = left.getURI();
+  // if (uri != null)
+  // {
+  // match.setLeftURI(uri.toString());
+  // }
+  // }
+  //
+  // if (right != null)
+  // {
+  // URI uri = right.getURI();
+  // if (uri != null)
+  // {
+  // match.setRightURI(uri.toString());
+  // }
+  // }
+  //
+  // if (origin != null)
+  // {
+  // URI uri = origin.getURI();
+  // if (uri != null)
+  // {
+  // match.setOriginURI(uri.toString());
+  // }
+  // }
+  //
+  // getComparison().getMatchedResources().add(match);
+  //
+  // // We need at least two resources to match them
+  // if (atLeastTwo(left == null, right == null, origin == null))
+  // {
+  // return;
+  // }
+  //
+  // final Iterator<? extends EObject> leftEObjects;
+  // if (left != null)
+  // {
+  // leftEObjects = getScope().getCoveredEObjects(left);
+  // }
+  // else
+  // {
+  // leftEObjects = Iterators.emptyIterator();
+  // }
+  // final Iterator<? extends EObject> rightEObjects;
+  // if (right != null)
+  // {
+  // rightEObjects = getScope().getCoveredEObjects(right);
+  // }
+  // else
+  // {
+  // rightEObjects = Iterators.emptyIterator();
+  // }
+  // final Iterator<? extends EObject> originEObjects;
+  // if (origin != null)
+  // {
+  // originEObjects = getScope().getCoveredEObjects(origin);
+  // }
+  // else
+  // {
+  // originEObjects = Iterators.emptyIterator();
+  // }
+  //
+  // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
+  //
+  // Iterables.addAll(getComparison().getMatches(), matches);
+  // }
+  //
+  // protected void match(EObject left, EObject right, EObject origin)
+  // {
+  // if (left == null || right == null)
+  // {
+  // throw new IllegalArgumentException();
+  // }
+  //
+  // final Iterator<? extends EObject> leftEObjects = Iterators.concat(Iterators.singletonIterator(left), getScope()
+  // .getChildren(left));
+  // final Iterator<? extends EObject> rightEObjects = Iterators.concat(Iterators.singletonIterator(right),
+  // getScope().getChildren(right));
+  // final Iterator<? extends EObject> originEObjects;
+  // if (origin != null)
+  // {
+  // originEObjects = Iterators.concat(Iterators.singletonIterator(origin), getScope().getChildren(origin));
+  // }
+  // else
+  // {
+  // originEObjects = Iterators.emptyIterator();
+  // }
+  //
+  // final Iterable<Match> matches = getEObjectMatcher().createMatches(leftEObjects, rightEObjects, originEObjects);
+  //
+  // Iterables.addAll(getComparison().getMatches(), matches);
+  // }
+  //
+  // protected IResourceMatcher getResourceMatcher()
+  // {
+  // return new StrategyResourceMatcher();
+  // }
+  //
+  // protected IEObjectMatcher getEObjectMatcher()
+  // {
+  // return eObjectMatcher;
+  // }
+  //
+  // protected Comparison getComparison()
+  // {
+  // if (comparison == null)
+  // {
+  // comparison = CompareFactory.eINSTANCE.createComparison();
+  // }
+  // return comparison;
+  // }
+  //
+  // protected IComparisonScope getScope()
+  // {
+  // return comparisonScope;
+  // }
+  //
+  // protected static boolean atLeastTwo(boolean condition1, boolean condition2, boolean condition3)
+  // {
+  // // CHECKSTYLE:OFF This expression is alone in its method, and documented.
+  // return condition1 && (condition2 || condition3) || condition2 && condition3;
+  // // CHECKSTYLE:ON
+  // }
+  //
+  // private static void associate(Comparison comparison, EMFCompareConfiguration configuration)
+  // {
+  // Iterator<Adapter> eAdapters = comparison.eAdapters().iterator();
+  // while (eAdapters.hasNext())
+  // {
+  // Adapter eAdapter = eAdapters.next();
+  // if (eAdapter.isAdapterForType(EMFCompareConfiguration.class))
+  // {
+  // eAdapters.remove();
+  // if (eAdapter instanceof Adapter.Internal)
+  // {
+  // ((Adapter.Internal)eAdapter).unsetTarget(comparison);
+  // }
+  // }
+  // }
+  //
+  // comparison.eAdapters().add(configuration);
+  // configuration.setTarget(comparison);
+  // }
+  // }
+  // }
 }
diff --git a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java
index c5a93c5..47e8112 100644
--- a/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java
+++ b/plugins/org.eclipse.emf.cdo.compare/src/org/eclipse/emf/cdo/compare/DelegatingComparison.java
@@ -17,10 +17,10 @@
 import org.eclipse.emf.compare.Comparison;
 import org.eclipse.emf.compare.Conflict;
 import org.eclipse.emf.compare.Diff;
-import org.eclipse.emf.compare.EMFCompareConfiguration;
 import org.eclipse.emf.compare.Equivalence;
 import org.eclipse.emf.compare.Match;
 import org.eclipse.emf.compare.MatchResource;
+import org.eclipse.emf.compare.utils.IEqualityHelper;
 import org.eclipse.emf.ecore.EClass;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EOperation;
@@ -104,9 +104,9 @@
     return delegate.eContainer();
   }
 
-  public EMFCompareConfiguration getConfiguration()
+  public IEqualityHelper getEqualityHelper()
   {
-    return delegate.getConfiguration();
+    return delegate.getEqualityHelper();
   }
 
   public EList<Diff> getDifferences()