Class ProximityEObjectMatcher

java.lang.Object
org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher
All Implemented Interfaces:
IEObjectMatcher, ScopeQuery

public class ProximityEObjectMatcher
extends java.lang.Object
implements IEObjectMatcher, ScopeQuery
This matcher is using a distance function to match EObject. It guarantees that elements are matched with the other EObject having the lowest distance. If two elements have the same distance regarding the other EObject it will arbitrary pick one. (You should probably not rely on this and make sure your distance only return 0 if both EObject have the very same content). The matcher will try to use the fact that it is a distance to achieve a suitable scalability. It is also build on the following assumptions :
  • Most EObjects have no difference and have their corresponding EObject on the other sides of the model (right and origins)
  • Two consecutive calls on the distance function with the same parameters will give the same distance.
The scalability you'll get will highly depend on the complexity of the distance function. The implementation is not caching any distance result from two EObjects.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static interface  ProximityEObjectMatcher.DistanceFunction
    This represent a distance function used by the ProximityEObjectMatcher to compare EObjects and retrieve the closest EObject from one side to another.
  • Constructor Summary

    Constructors 
    Constructor Description
    ProximityEObjectMatcher​(ProximityEObjectMatcher.DistanceFunction meter)
    Create the matcher using the given distance function.
  • Method Summary

    Modifier and Type Method Description
    void createMatches​(Comparison comparison, java.util.Iterator<? extends EObject> leftEObjects, java.util.Iterator<? extends EObject> rightEObjects, java.util.Iterator<? extends EObject> originEObjects, Monitor monitor)
    This will be called by the match engine to determine matches between EObjects.
    boolean isInScope​(EObject eContainer)
    Check whether the object is in the scope or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • createMatches

      public void createMatches​(Comparison comparison, java.util.Iterator<? extends EObject> leftEObjects, java.util.Iterator<? extends EObject> rightEObjects, java.util.Iterator<? extends EObject> originEObjects, Monitor monitor)
      This will be called by the match engine to determine matches between EObjects.

      The implementation should update the given comparison object by adding the Matches it detect. These matches should include both matching and unmatchings EObjects (i.e. EObjects that can be matched in all three lists, EObjects that cna be matched in only two of the three lists, and EObjects that can only be found in one of the three.

      Specified by:
      createMatches in interface IEObjectMatcher
      Parameters:
      comparison - the comparison to update.
      leftEObjects - An iterator over the EObjects that could be found in the left side.
      rightEObjects - An iterator over the EObjects that could be found in the right side.
      originEObjects - And iterator over the EObject that may be considered ancestors of the couples that can be detected in the left and right sides.
      monitor - The monitor to report progress or to check for cancellation
    • isInScope

      public boolean isInScope​(EObject eContainer)
      Check whether the object is in the scope or not.
      Specified by:
      isInScope in interface ScopeQuery
      Parameters:
      eContainer - any EObject.
      Returns:
      true if the Object is in scope. False otherwise.