java – Orika使用BoundMapperFacade而不是MapperFacade

Orika Performance Tuning指南说

> BoundMapperFacade比MapperFacade&
>使用BoundMapperFacade的非循环版本.

我的代码如下所示

System.setProperty(OrikaSystemProperties.WRITE_SOURCE_FILES, "false");
System.setProperty(OrikaSystemProperties.WRITE_CLASS_FILES, "false");

MapperFactory factory = new DefaultMapperFactory.Builder().build();

//Then during initialization quite a few code is added to classMap like below with all the classes non cyclic

factory.classMap(Folder.class, FolderUI.class).byDefault().register();
factory.classMap(VCManager.class, VCManagerUI.class).byDefault().register();
factory.classMap(NSXManager.class, NSXManagerUI.class).byDefault().register();
factory.classMap(L3SwitchManager.class, BaseManagerUI.class).byDefault().register();

...

MapperFacade mapper = factory.getMapperFacade();

每当我需要查看时,我正在做mapper.map(输入,输出)

有人能告诉我如何在这种情况下使用BoundedMapperFacade,因为我在MapperFacade中没有看到任何getBoundedMapperFacade.

Orika版本 – 1.4.2

最佳答案 MapperFactory通过决定参数为您提供正确的类.如果你使用方法getMapperFacade()和你要映射的类以及要映射到的类,它会为你提供BoundMapperFacade:

BoundMapperFacade<From,To> mapper = mapperFactory.getMapperFacade(From.class, To.class);
点赞