private Mapper getMapper(
      TypeElement element, MapperConfiguration mapperConfig, List<SourceMethod> methods) {
    List<MapperReference> mapperReferences = mappingContext.getMapperReferences();
    List<MappingMethod> mappingMethods = getMappingMethods(mapperConfig, methods);
    mappingMethods.addAll(mappingContext.getUsedVirtualMappings());
    mappingMethods.addAll(mappingContext.getMappingsToGenerate());

    Mapper mapper =
        new Mapper.Builder()
            .element(element)
            .mappingMethods(mappingMethods)
            .mapperReferences(mapperReferences)
            .options(options)
            .versionInformation(versionInformation)
            .decorator(
                getDecorator(
                    element,
                    methods,
                    mapperConfig.implementationName(),
                    mapperConfig.implementationPackage()))
            .typeFactory(typeFactory)
            .elementUtils(elementUtils)
            .extraImports(getExtraImports(element))
            .implName(mapperConfig.implementationName())
            .implPackage(mapperConfig.implementationPackage())
            .build();

    return mapper;
  }
  private SortedSet<Type> getExtraImports(TypeElement element) {
    SortedSet<Type> extraImports = new TreeSet<Type>();

    MapperConfiguration mapperConfiguration = MapperConfiguration.getInstanceOn(element);

    for (TypeMirror extraImport : mapperConfiguration.imports()) {
      Type type = typeFactory.getType(extraImport);
      extraImports.add(type);
    }

    // Add original package if a dest package has been set
    if (!"default".equals(mapperConfiguration.implementationPackage())) {
      extraImports.add(typeFactory.getType(element));
    }

    return extraImports;
  }