Class MatchUtil

java.lang.Object
org.eclipse.emf.compare.utils.MatchUtil

public final class MatchUtil extends Object
This utility class holds methods that will be used by the diff and merge processes.
  • Method Details

    • getOriginObject

      public static EObject getOriginObject(Comparison comparison, EObject object)
      Get the object which is the origin value from the given matching object.
      Parameters:
      comparison - The comparison.
      object - The given object.
      Returns:
      The origin value.
    • matchingIndices

      public static boolean matchingIndices(Match match, EStructuralFeature feature, Object value1, Object value2)
      This will be used whenever we check for conflictual MOVEs in order to determine whether we have a pseudo conflict or a real conflict.

      Namely, this will retrieve the value of the given feature on the right and left sides of the given match, then check whether the two given values are on the same index.

      Note that no sanity checks will be made on either the match's sides or the feature.

      Parameters:
      match - Match for which we need to check a feature.
      feature - The feature which values we need to check.
      value1 - First of the two values which index we are to compare.
      value2 - Second of the two values which index we are to compare.
      Returns:
      true if the two given values are located at the same index in the given feature's values list, false otherwise.
      Since:
      3.4
    • computeIndex

      public static int computeIndex(Match match, EStructuralFeature feature, Object value, DifferenceSource side)
      Compute the index of an object in the list of elements of a given match+feature on a given side. This index is computed without taking objects that have a diff into account, except if this diff is an ADD.
      Parameters:
      match - The match
      feature - The structural feature
      value - The object the index of which must be computed
      side - The side on which to compute the index
      Returns:
      The index of the given object.
      Since:
      3.4
    • hasDeleteDiff

      public static boolean hasDeleteDiff(Match match, EStructuralFeature feature, Object value)
      Checks whether the given value has been deleted from the given feature of match .
      Parameters:
      match - The match which differences we'll check.
      feature - The feature on which we expect a difference.
      value - The value we expect to have been removed from feature.
      Returns:
      true if there is such a Diff on match, false otherwise.
      Since:
      3.4
    • hasDiff

      public static boolean hasDiff(Match match, EStructuralFeature feature, Object value)
      Checks whether the given match presents a difference of any kind on the given feature's value.
      Parameters:
      match - The match which differences we'll check.
      feature - The feature on which we expect a difference.
      value - The value we expect to have changed inside feature.
      Returns:
      true if there is such a Diff on match, false otherwise.
      Since:
      3.4
    • getOriginValue

      public static EObject getOriginValue(Comparison comparison, ReferenceChange difference)
      From a given mono-valued reference change, get the origin value.
      Parameters:
      comparison - The comparison.
      difference - The given reference change.
      Returns:
      The origin value.
    • getOriginContainer

      public static EObject getOriginContainer(Comparison comparison, Diff difference)
      Get the business model object containing the given difference in the origin side.
      Parameters:
      comparison - The comparison.
      difference - The difference.
      Returns:
      The object.
    • getContainer

      public static EObject getContainer(Comparison comparison, Diff difference)
      Get the business model object containing the given difference.
      Parameters:
      comparison - The comparison.
      difference - The difference.
      Returns:
      The object.
    • featureContains

      public static boolean featureContains(EObject eObject, EStructuralFeature feature, Object value)
      Determines whether the given feature of the given EObject contains the provided value, while correctly handling proxies (in other words, in case of proxies, the proxy URI is compared instead of the objects, which would otherwise lead to false negatives).
      Parameters:
      eObject - The object of which a feature is to be checked
      feature - The feature of which containment is to be checked
      value - The value which is to be verified in the feature
      Returns:
      true if the feature contains the given value
    • getValue

      public static Object getValue(Diff input)
      Get the value of any difference.
      Parameters:
      input - The difference.
      Returns:
      the value of the difference.
    • getStructuralFeature

      public static EStructuralFeature getStructuralFeature(Diff input)
      Get the structural feature of any difference.
      Parameters:
      input - The difference.
      Returns:
      the structural feature.
    • getMatchedObject

      public static EObject getMatchedObject(Match m, DifferenceSource side)
      Get the object matched by a Match on a given side.
      Parameters:
      m - The match, must not be null
      side - The side for which we want the matched value, use null for ORIGIN.
      Returns:
      The value matched by this match on the given side.
      Since:
      3.4
    • findAddOrDeleteContainmentDiffs

      public static Iterable<Diff> findAddOrDeleteContainmentDiffs(Match match)
      Get the potential ReferenceChanges that represent add/delete containment differences in the parent Match of the given Match.
      Parameters:
      match - the given Match.
      Returns:
      the potential ReferenceChanges that represent add/delete containment differences in the parent Match of the given Match, null otherwise.