class DefaultCopierFactoryManager implements com.hotels.bdp.circustrain.api.copier.CopierFactoryManager {

  @Override
  public CopierFactory getCopierFactory(Path sourceLocation, Path replicaLocation, Map<String, Object> copierOptions) {
    String sourceScheme = sourceLocation.toUri().getScheme();
    String replicaScheme = replicaLocation.toUri().getScheme();
    if (copierOptions.containsKey(COPIER_FACTORY_CLASS)) {
      for (CopierFactory copierFactory : copierFactories) {
        final String copierFactoryClassName = copierFactory.getClass().getName();
        if (copierFactoryClassName.equals(copierOptions.get(COPIER_FACTORY_CLASS).toString())) {
          LOG.debug("Found CopierFactory '{}' using config", copierFactoryClassName);
          return copierFactory;
        }
      }
    } else {
      for (CopierFactory copierFactory : copierFactories) {
        final String copierFactoryClassName = copierFactory.getClass().getName();
        if (copierFactory.supportsSchemes(sourceScheme, replicaScheme)) {
          LOG
              .debug("Found CopierFactory '{}' for sourceScheme '{}' and replicaScheme '{}'", copierFactoryClassName,
                  sourceScheme, replicaScheme);
          return copierFactory;
        }
      }
    }
    throw new UnsupportedOperationException("No CopierFactory that suppports sourceScheme '"
        + sourceScheme
        + "' and replicaScheme '"
        + replicaScheme
        + "'");
  }

  @Autowired public  DefaultCopierFactoryManager(List<CopierFactory> copierFactories);

}