Search in sources :

Example 1 with ProximityEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher in project tdq-studio-se by Talend.

the class ModelElementMatchEngine method createDQEObjectMatcher.

/**
 * Creates and configures an {@link IEObjectMatcher} with the strategy given by {@code useIDs}. The {@code cache}
 * will be used to cache some expensive computation (should better a LoadingCache).
 *
 * @param useIDs which strategy the return IEObjectMatcher must follow.
 * @param weightProviderRegistry the match engine needs a WeightProvider in case of this match engine do not use
 * identifiers.
 * @return a new IEObjectMatcher.
 */
public static IEObjectMatcher createDQEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry) {
    final IEObjectMatcher matcher;
    final ModelElementEditonDistance editionDistance = new ModelElementEditonDistance(weightProviderRegistry);
    final CachingDistance cachedDistance = new CachingDistance(editionDistance);
    switch(useIDs) {
        case NEVER:
            matcher = new ProximityEObjectMatcher(cachedDistance);
            break;
        case ONLY:
            matcher = new IdentifierEObjectMatcher();
            break;
        case WHEN_AVAILABLE:
        // fall through to default
        default:
            // Use an ID matcher, delegating to proximity when no ID is available
            final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(cachedDistance);
            matcher = new IdentifierEObjectMatcher(contentMatcher);
            break;
    }
    return matcher;
}
Also used : ProximityEObjectMatcher(org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher) CachingDistance(org.eclipse.emf.compare.match.eobject.CachingDistance) IdentifierEObjectMatcher(org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher)

Aggregations

CachingDistance (org.eclipse.emf.compare.match.eobject.CachingDistance)1 IEObjectMatcher (org.eclipse.emf.compare.match.eobject.IEObjectMatcher)1 IdentifierEObjectMatcher (org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher)1 ProximityEObjectMatcher (org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher)1