class ResourcesFinder {

  Map<Location, List<Resource>> findResources(FlywayConfiguration configuration)
      throws IOException {
    final String prefix = configuration.getSqlMigrationPrefix();
    final String suffix = configuration.getSqlMigrationSuffix();
    final ClassPathScanner cpScanner = new ClassPathScanner(configuration.getClassLoader());
    final FileSystemScanner fsScanner = new FileSystemScanner();
    final Map<Location, List<Resource>> resources = new HashMap<>();
    for (String rawLocation : configuration.getLocations()) {
      final Location location = new Location(rawLocation);
      if (location.isClassPath()) {
        resources.put(location, newArrayList(cpScanner.scanForResources(location, prefix, suffix)));
      } else {
        resources.put(location, newArrayList(fsScanner.scanForResources(location, prefix, suffix)));
      }
    }
    return resources;
  }

}