Class IdentifierEObjectMatcher
java.lang.Object
org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher
- All Implemented Interfaces:
IEObjectMatcher
This implementation of an
IEObjectMatcher
will create Match
es based on the input EObjects
identifiers (either XMI:ID or attribute ID) alone.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The default function used to retrieve IDs from EObject. -
Constructor Summary
ConstructorDescriptionCreates an ID based matcher without any delegate.IdentifierEObjectMatcher
(com.google.common.base.Function<EObject, String> idComputation) Creates an ID based matcher computing the ID with the given function.IdentifierEObjectMatcher
(IEObjectMatcher delegateWhenNoID) Creates an ID based matcher with the given delegate when no ID can be found.IdentifierEObjectMatcher
(IEObjectMatcher delegateWhenNoID, com.google.common.base.Function<EObject, String> idComputation) Create an ID based matcher with a delegate which is going to be called when no ID is found for a given EObject. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createMatches
(Comparison comparison, Iterator<? extends EObject> leftEObjects, Iterator<? extends EObject> rightEObjects, Iterator<? extends EObject> originEObjects, Monitor monitor) This will be called by the match engine to determine matches between EObjects.protected void
doDelegation
(Comparison comparison, List<EObject> leftEObjectsNoID, List<EObject> rightEObjectsNoID, List<EObject> originEObjectsNoID, Monitor monitor) Execute matching process for the delegated IEObjectMatcher.protected EObject
getParentEObject
(EObject eObject) This method is used to determine the parent objects during matching.matchPerId
(Iterator<? extends EObject> leftEObjects, Iterator<? extends EObject> rightEObjects, Iterator<? extends EObject> originEObjects, List<EObject> leftEObjectsNoID, List<EObject> rightEObjectsNoID, List<EObject> originEObjectsNoID) Matches the EObject per ID.
-
Constructor Details
-
IdentifierEObjectMatcher
public IdentifierEObjectMatcher()Creates an ID based matcher without any delegate. -
IdentifierEObjectMatcher
Creates an ID based matcher with the given delegate when no ID can be found.- Parameters:
delegateWhenNoID
- the matcher to delegate to when no ID is found.
-
IdentifierEObjectMatcher
Creates an ID based matcher computing the ID with the given function.- Parameters:
idComputation
- the function used to compute the ID.
-
IdentifierEObjectMatcher
public IdentifierEObjectMatcher(IEObjectMatcher delegateWhenNoID, com.google.common.base.Function<EObject, String> idComputation) Create an ID based matcher with a delegate which is going to be called when no ID is found for a given EObject. It is computing the ID with the given function- Parameters:
delegateWhenNoID
- the delegate matcher to use when no ID is found.idComputation
- the function used to compute the ID.
-
-
Method Details
-
createMatches
public void createMatches(Comparison comparison, Iterator<? extends EObject> leftEObjects, Iterator<? extends EObject> rightEObjects, Iterator<? extends EObject> originEObjects, Monitor monitor) This will be called by the match engine to determine matches between EObjects.The implementation should update the given comparison object by adding the Matches it detect. These matches should include both matching and unmatchings EObjects (i.e. EObjects that can be matched in all three lists, EObjects that cna be matched in only two of the three lists, and EObjects that can only be found in one of the three.
- Specified by:
createMatches
in interfaceIEObjectMatcher
- Parameters:
comparison
- the comparison to update.leftEObjects
- An iterator over the EObjects that could be found in the left side.rightEObjects
- An iterator over the EObjects that could be found in the right side.originEObjects
- And iterator over the EObject that may be considered ancestors of the couples that can be detected in the left and right sides.monitor
- The monitor to report progress or to check for cancellation
-
doDelegation
protected void doDelegation(Comparison comparison, List<EObject> leftEObjectsNoID, List<EObject> rightEObjectsNoID, List<EObject> originEObjectsNoID, Monitor monitor) Execute matching process for the delegated IEObjectMatcher.- Parameters:
comparison
- the comparison object that contains the matchesmonitor
- the monitor instance to track the matching progressleftEObjectsNoID
- remaining left objects after matchingrightEObjectsNoID
- remaining right objects after matchingoriginEObjectsNoID
- remaining origin objects after matching
-
matchPerId
protected Set<Match> matchPerId(Iterator<? extends EObject> leftEObjects, Iterator<? extends EObject> rightEObjects, Iterator<? extends EObject> originEObjects, List<EObject> leftEObjectsNoID, List<EObject> rightEObjectsNoID, List<EObject> originEObjectsNoID) Matches the EObject per ID.- Parameters:
leftEObjects
- the objects to match (left side).rightEObjects
- the objects to match (right side).originEObjects
- the objects to match (origin side).leftEObjectsNoID
- remaining left objects after matchingrightEObjectsNoID
- remaining right objects after matchingoriginEObjectsNoID
- remaining origin objects after matching- Returns:
- the match built in the process.
-
getParentEObject
This method is used to determine the parent objects during matching. The default implementation of this method returns the eContainer of the giveneObject
. Can be overwritten by clients to still allow proper matching when using a more complex architecture.- Parameters:
eObject
- TheEObject
for which the parent object is to determine.- Returns:
- The parent of the given
eObject
. - Since:
- 3.2
-