Package org.eclipse.emf.compare.utils
Class MatchUtil
java.lang.Object
org.eclipse.emf.compare.utils.MatchUtil
This utility class holds methods that will be used by the diff and merge processes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static boolean
featureContains
(EObject eObject, EStructuralFeature feature, Object value) Determines whether the given feature of the givenEObject
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).Get the potential ReferenceChanges that represent add/delete containment differences in the parent Match of the given Match.static EObject
getContainer
(Comparison comparison, Diff difference) Get the business model object containing the givendifference
.static EObject
getMatchedObject
(Match m, DifferenceSource side) Get the object matched by a Match on a given side.static EObject
getOriginContainer
(Comparison comparison, Diff difference) Get the business model object containing the givendifference
in the origin side.static EObject
getOriginObject
(Comparison comparison, EObject object) Get the object which is the origin value from the given matchingobject
.static EObject
getOriginValue
(Comparison comparison, ReferenceChange difference) From a given mono-valued reference change, get the origin value.static EStructuralFeature
getStructuralFeature
(Diff input) Get the structural feature of any difference.static Object
Get the value of any difference.static boolean
hasDeleteDiff
(Match match, EStructuralFeature feature, Object value) Checks whether the givenvalue
has been deleted from the givenfeature
ofmatch
.static boolean
hasDiff
(Match match, EStructuralFeature feature, Object value) Checks whether the givenmatch
presents a difference of any kind on the givenfeature
'svalue
.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.
-
Method Details
-
getOriginObject
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
feature
on 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:
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 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
Checks whether the givenvalue
has been deleted from the givenfeature
ofmatch
.- 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:
true
if there is such a Diff onmatch
,false
otherwise.- Since:
- 3.4
-
hasDiff
Checks whether the givenmatch
presents 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:
true
if there is such a Diff onmatch
,false
otherwise.- Since:
- 3.4
-
getOriginValue
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
Get the business model object containing the givendifference
in the origin side.- Parameters:
comparison
- The comparison.difference
- The difference.- Returns:
- The object.
-
getContainer
Get the business model object containing the givendifference
.- Parameters:
comparison
- The comparison.difference
- The difference.- Returns:
- The object.
-
featureContains
Determines whether the given feature of the givenEObject
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 checkedfeature
- The feature of which containment is to be checkedvalue
- The value which is to be verified in the feature- Returns:
true
if the feature contains the given value
-
getValue
Get the value of any difference.- Parameters:
input
- The difference.- Returns:
- the value of the difference.
-
getStructuralFeature
Get the structural feature of any difference.- Parameters:
input
- The difference.- Returns:
- the structural feature.
-
getMatchedObject
Get the object matched by a Match on a given side.- Parameters:
m
- The match, must not benull
side
- The side for which we want the matched value, usenull
for ORIGIN.- Returns:
- The value matched by this match on the given side.
- Since:
- 3.4
-
findAddOrDeleteContainmentDiffs
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.
-