javajava-8orika

Orika using BoundMapperFacade instead of MapperFacade


Orika Performance Tuning guide says

  1. BoundMapperFacade is more performant than MapperFacade &
  2. Use a non-cyclic version of BoundMapperFacade.

My code looks something like below

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();

Whenever I need to do a look up I am doing mapper.map(input, output)

Can someone let me know how can I use BoundedMapperFacade in this case as I don't see any getBoundedMapperFacade in MapperFacade.

Orika Version - 1.4.2


Solution

  • MapperFactory gives you the correct class by deciding on the parameters. If you use the method getMapperFacade() with the class you want to map from and the class you want to map to, it gives you the BoundMapperFacade:

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