2013-04-05 60 views
1

EMF的版本比較:2.1.0 M6(2013年3月19日17:50)與EMF編制問題比較碼

我想使用獨立於this guide比較作爲解釋。我得到下面的編譯錯誤

The method setMatchEngine(IMatchEngine) is undefined for the type EMFCompare.Builder 

爲下面的代碼

// Configure EMF Compare 
IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER); 
IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory()); 
IMatchEngine matchEngine = new DefaultMatchEngine(matcher, comparisonFactory); 
EMFCompare comparator = EMFCompare.builder().setMatchEngine(matchEngine).build(); 

我看到setMatchEngine被其它API代替如圖所示如下圖。我不知道如何使用該API指定新的matchEngine

enter image description here

回答

2

這些API已經改變了M6(API的現在在他們的最後階段2.1.0儘可能清除而言)。 「如何使用API​​」的一個很好的來源是EMF Compare的單元測試,如果您的工作區中有代碼。

對於您的特定用途的情況下,代碼將看起來像這樣:

IMatchEngine.Factory factory = new MatchEngineFactoryImpl(UseIdentifiers.NEVER); 
IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl(); 
matchEngineRegistry .add(factory); 
EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build(); 

注意,使用默認的註冊表(EMFCompare.builder().build();)就足以在大多數情況下......除了當你真的不能讓EMF比較使用ID:p。

[編輯:小記:我們現在已經用正確的信息更新了wiki,感謝您的反饋;]]