Class ComparisonUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
bothArePlatformResourcesAndOnlyOneExists
(Resource leftResource, Resource rightResource) Checks if both resources are platform resources and only one exists.static boolean
bothResourceHaveResourceSet
(Resource leftResource, Resource rightResource) Checks if both resources have resource set.static void
Deletes
the givendiff
.static Comparison
getComparison
(Diff diff) Returns the comparison associated with the given diff.static Comparison
getComparison
(EObject object) Returns the comparison associated with the given object.getDirectSubDiffs
(boolean leftToRight) When merging aDiff
, returns the first level of sub diffs of this given diff, and all associated diffs (seeDiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)
) of these sub diffs.static EObject
getExpectedSide
(Match match, DifferenceSource source, boolean mergeRightToLeft) Determines the side of the givenMatch
which represents the model state the other side will be changed to.getSubDiffs
(boolean leftToRight) When merging aDiff
, returns the sub diffs of this given diff, and all associated diffs (seeDiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)
) of these sub diffs.static boolean
isAddOrSetDiff
(Diff difference) Checks if the given difference is either an addition or a "set" from the default value to a new reference.static boolean
isContainedInFeatureMap
(EObject object) Determines if the givenEObject
is contained directly within a FeatureMap by checking theEAnnotation
s.static boolean
isDeleteOrUnsetDiff
(Diff difference) Checks if the given difference is either a deletion or a "unset" to the default value.static boolean
isFeatureMapContainment
(Diff diff) Checks whether the given diff corresponds to a feature map containment change.static EObject
moveElementGetExpectedContainer
(Comparison comparison, FeatureMapChange diff, boolean rightToLeft) Get the expected target container in case of a move.
-
Method Details
-
getSubDiffs
When merging aDiff
, returns the sub diffs of this given diff, and all associated diffs (seeDiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)
) of these sub diffs.If the diff is an
AttributeChange
, aFeatureMapChange
or aResourceAttachmentChange
, this method will return an empty iterable.If the diff is a
ReferenceChange
this method will return all differences contained in the match that contains the value of the reference change, and all associated diffs of these differences.- Parameters:
leftToRight
- the direction of merge.- Returns:
- an iterable containing the sub diffs of this given diff, and all associated diffs of these sub diffs.
- Since:
- 3.0
-
getDirectSubDiffs
public static com.google.common.base.Function<Diff,Iterable<Diff>> getDirectSubDiffs(boolean leftToRight) When merging aDiff
, returns the first level of sub diffs of this given diff, and all associated diffs (seeDiffUtil#getAssociatedDiffs(Iterable, boolean, Diff)
) of these sub diffs.If the diff is an
AttributeChange
, aFeatureMapChange
or aResourceAttachmentChange
, this method will return an empty iterable.If the diff is a
ReferenceChange
this method will return the first level differences contained in the match that contains the value of the reference change, and all associated diffs of these differences.- Parameters:
leftToRight
- the direction of merge.- Returns:
- an iterable containing the first level of sub diffs of this given diff, and all associated diffs of these sub diffs.
- Since:
- 3.3
-
isAddOrSetDiff
Checks if the given difference is either an addition or a "set" from the default value to a new reference.- Parameters:
difference
- The given difference.- Returns:
true
if this is an addition or "set" diff.
-
isDeleteOrUnsetDiff
Checks if the given difference is either a deletion or a "unset" to the default value.- Parameters:
difference
- The given difference.- Returns:
true
if this is a deletion or "unset" diff.
-
isFeatureMapContainment
Checks whether the given diff corresponds to a feature map containment change. This holds true for differences on feature map containment references' values.- Parameters:
diff
- The diff to consider.- Returns:
true
if the givendiff
is to be considered a containment change,false
otherwise.
-
moveElementGetExpectedContainer
public static EObject moveElementGetExpectedContainer(Comparison comparison, FeatureMapChange diff, boolean rightToLeft) Get the expected target container in case of a move.- Parameters:
comparison
- The comparison object.diff
- The diff we are currently merging.rightToLeft
- Whether we should move the value in the left or right side.- Returns:
- The expected target container if found,
null
otherwise.
-
getComparison
Returns the comparison associated with the given object. The given object is expected to be an instance of one of the Class from the ComparePackage model.- Parameters:
object
- the object from which the comparison should be retrieved.- Returns:
- the comparison.
-
getComparison
Returns the comparison associated with the given diff.- Parameters:
diff
- The diff, which must either have a match or a MatchResource container, otherwise a NPE will be thrown.- Returns:
- The comparison that contains the given diff, or
null
if there's none.
-
getExpectedSide
public static EObject getExpectedSide(Match match, DifferenceSource source, boolean mergeRightToLeft) Determines the side of the givenMatch
which represents the model state the other side will be changed to.- Parameters:
match
- The match whose side is returned.source
- The source from which side the differences are determined.mergeRightToLeft
- The direction of the merge.- Returns:
- The side of the given
match
which represents the desired model state in regards to the givenDifferenceSource
andMergeDirection
.
-
isContainedInFeatureMap
Determines if the givenEObject
is contained directly within a FeatureMap by checking theEAnnotation
s.- Parameters:
object
- The object to check.- Returns:
- if the
object
is directly contained within a FeatureMap.
-
bothArePlatformResourcesAndOnlyOneExists
public static boolean bothArePlatformResourcesAndOnlyOneExists(Resource leftResource, Resource rightResource) Checks if both resources are platform resources and only one exists.- Parameters:
leftResource
- the first resource to check.rightResource
- the second resource to check.- Returns:
- true if both resources are platform resources and only one exists, false otherwise.
-
bothResourceHaveResourceSet
Checks if both resources have resource set.- Parameters:
leftResource
- the first resource to check.rightResource
- the second resource to check.- Returns:
- true if both resources have resource set, false otherwise.
-
delete
Deletes
the givendiff
.Conflicts and equivalences of the
diff
will also be removed if they get meaningless after thediff
has been deleted. A conflict is meaningless, if it has diffs only on one side after the deletion. An equivalence is meaningless, if it has only one diff left.- Parameters:
diff
- The diff to delete.
-