Package org.eclipse.emf.compare.utils
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcomputeIndex(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.static booleanfeatureContains(EObject eObject, EStructuralFeature feature, Object value)Determines whether the given feature of the givenEObjectcontains 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).static Iterable<Diff>findAddOrDeleteContainmentDiffs(Match match)Get the potential ReferenceChanges that represent add/delete containment differences in the parent Match of the given Match.static EObjectgetContainer(Comparison comparison, Diff difference)Get the business model object containing the givendifference.static EObjectgetMatchedObject(Match m, DifferenceSource side)Get the object matched by a Match on a given side.static EObjectgetOriginContainer(Comparison comparison, Diff difference)Get the business model object containing the givendifferencein the origin side.static EObjectgetOriginObject(Comparison comparison, EObject object)Get the object which is the origin value from the given matchingobject.static EObjectgetOriginValue(Comparison comparison, ReferenceChange difference)From a given mono-valued reference change, get the origin value.static EStructuralFeaturegetStructuralFeature(Diff input)Get the structural feature of any difference.static ObjectgetValue(Diff input)Get the value of any difference.static booleanhasDeleteDiff(Match match, EStructuralFeature feature, Object value)Checks whether the givenvaluehas been deleted from the givenfeatureofmatch.static booleanhasDiff(Match match, EStructuralFeature feature, Object value)Checks whether the givenmatchpresents a difference of any kind on the givenfeature'svalue.static booleanmatchingIndices(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.
-
-
-
Method Detail
-
getOriginObject
public static EObject getOriginObject(Comparison comparison, EObject object)
Get the object which is the origin value from the given matchingobject.- 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
featureon the right and left sides of the givenmatch, 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:
trueif the two given values are located at the same index in the given feature's values list,falseotherwise.- 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 matchfeature- The structural featurevalue- The object the index of which must be computedside- 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 givenvaluehas been deleted from the givenfeatureofmatch.- 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 fromfeature.- Returns:
trueif there is such a Diff onmatch,falseotherwise.- Since:
- 3.4
-
hasDiff
public static boolean hasDiff(Match match, EStructuralFeature feature, Object value)
Checks whether the givenmatchpresents a difference of any kind on the givenfeature'svalue.- 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 insidefeature.- Returns:
trueif there is such a Diff onmatch,falseotherwise.- 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 givendifferencein 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 givendifference.- 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 givenEObjectcontains 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 checkedfeature- The feature of which containment is to be checkedvalue- The value which is to be verified in the feature- Returns:
trueif 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 benullside- The side for which we want the matched value, usenullfor 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,
nullotherwise.
-
-