Class CachingDistance

java.lang.Object
org.eclipse.emf.compare.match.eobject.CachingDistance
All Implemented Interfaces:
ProximityEObjectMatcher.DistanceFunction

public class CachingDistance
extends java.lang.Object
implements ProximityEObjectMatcher.DistanceFunction
This class wraps a DistanceFunction and cache its result. Any call to distance(a,b) will be cached and the same value will be returned to distance(b,a).
Since:
3.1
  • Constructor Summary

    Constructors 
    Constructor Description
    CachingDistance​(ProximityEObjectMatcher.DistanceFunction wrapped)
    Create a new caching distance.
  • Method Summary

    Modifier and Type Method Description
    boolean areIdentic​(Comparison inProgress, EObject a, EObject b)
    Check that two objects are equals from the distance function point of view (distance should be 0) You should prefer this method when you just want to check objects are not equals enabling the distance to stop sooner.
    double distance​(Comparison inProgress, EObject a, EObject b)
    Return the distance between two EObjects.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • distance

      public double distance​(Comparison inProgress, EObject a, EObject b)
      Return the distance between two EObjects. When the two objects should considered as completely different the implementation is expected to return Double.MAX_VALUE.
      Specified by:
      distance in interface ProximityEObjectMatcher.DistanceFunction
      Parameters:
      inProgress - the comparison being processed right now. This might be used for the distance to retrieve other matches for instance.
      a - first object.
      b - second object.
      Returns:
      the distance between the two EObjects or Double.MAX_VALUE when the objects are considered too different to be the same.
    • areIdentic

      public boolean areIdentic​(Comparison inProgress, EObject a, EObject b)
      Check that two objects are equals from the distance function point of view (distance should be 0) You should prefer this method when you just want to check objects are not equals enabling the distance to stop sooner.
      Specified by:
      areIdentic in interface ProximityEObjectMatcher.DistanceFunction
      Parameters:
      inProgress - the comparison being processed right now. This might be used for the distance to retrieve other matches for instance.
      a - first object.
      b - second object.
      Returns:
      true of the two objects are equals, false otherwise.