Package org.eclipse.emf.compare.match.eobject

# Class IdentifierEObjectMatcher

java.lang.Object
org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher

All Implemented Interfaces:
  `IEObjectMatcher`

public class IdentifierEObjectMatcher extends Object implements 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

Nested Classes
Modifier and Type
Class
Description
`static class`
`IdentifierEObjectMatcher.DefaultIDFunction`
The default function used to retrieve IDs from EObject.

## Constructor Summary

Constructors
Constructor
Description
`IdentifierEObjectMatcher()`
Creates 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 Type
Method
Description
`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.
`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.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### IdentifierEObjectMatcher

public IdentifierEObjectMatcher()
Creates an ID based matcher without any delegate.

### IdentifierEObjectMatcher

public IdentifierEObjectMatcher(IEObjectMatcher delegateWhenNoID)
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

public IdentifierEObjectMatcher(com.google.common.base.Function<EObject,String> idComputation)
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 interface `IEObjectMatcher`
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 matches
  `leftEObjectsNoID` - remaining left objects after matching
  `rightEObjectsNoID` - remaining right objects after matching
  `originEObjectsNoID` - remaining origin objects after matching
  `monitor` - the monitor instance to track the matching progress

### 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 matching
  `rightEObjectsNoID` - remaining right objects after matching
  `originEObjectsNoID` - remaining origin objects after matching
Returns:
  the match built in the process.

### getParentEObject

protected EObject getParentEObject(EObject eObject)
This method is used to determine the parent objects during matching. The default implementation of this method returns the eContainer of the given `eObject`. Can be overwritten by clients to still allow proper matching when using a more complex architecture.

Parameters:
  `eObject` - The `EObject` for which the parent object is to determine.
Returns:
  The parent of the given `eObject`.
Since:
  3.2