【问题标题】:Compilation issue with EMF Compare codeEMF 比较代码的编译问题
【发布时间】:2013-03-28 10:12:44
【问题描述】:

EMF 比较版本:2.1.0 M6 (2013/03/19 17:50)

我正在尝试按照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

【问题讨论】:

    标签: java eclipse eclipse-emf emf emf-compare


    【解决方案1】:

    这些 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 Compare 使用 ID:p。

    [编辑:一个小提示:我们现在已经用准确的信息更新了 wiki,感谢您的反馈;)]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 2013-05-22
      • 2018-04-20
      • 2013-03-30
      • 2012-05-07
      • 2017-01-28
      • 1970-01-01
      相关资源
      最近更新 更多