private Importer createImporter(final InputFile file, final SpecificationListBuilder builder) { final ImporterFactory importerFactory = this.factoryLoader.getImporterFactory(file); final Importer importer = importerFactory.createImporter(file, builder); LOG.fine(() -> "Created importer of type '" + importer.getClass().getSimpleName() + "' for file '" + file + "'"); return importer; } }
/** * Check if any {@link ImporterFactory} supports importing the given * {@link InputFile}. * * @param file * the file for which to check if an importer exists. * @return <code>true</code> if an importer exists, else <code>false</code>. */ public boolean supportsFile(final InputFile file) { final boolean supported = !getMatchingFactories(file).isEmpty(); LOG.finest(() -> "File " + file + " is supported = " + supported); return supported; }
private ImporterService createImporterService(final ImportSettings settings) { final ImporterContext context = new ImporterContext(settings); final InitializingServiceLoader<ImporterFactory, ImporterContext> serviceLoader = InitializingServiceLoader .load(ImporterFactory.class, context); final ImporterService service = new ImporterServiceImpl( new ImporterFactoryLoader(serviceLoader), settings); context.setImporterService(service); return service; }
private ImporterService createImporterService(final ImportSettings settings) { final ImporterContext context = new ImporterContext(settings); final InitializingServiceLoader<ImporterFactory, ImporterContext> serviceLoader = InitializingServiceLoader .load(ImporterFactory.class, context); final ImporterService service = new ImporterServiceImpl( new ImporterFactoryLoader(serviceLoader), settings); context.setImporterService(service); return service; }
/** * Check if any {@link ImporterFactory} supports importing the given * {@link InputFile}. * * @param file * the file for which to check if an importer exists. * @return <code>true</code> if an importer exists, else <code>false</code>. */ public boolean supportsFile(final InputFile file) { final boolean supported = !getMatchingFactories(file).isEmpty(); LOG.finest(() -> "File " + file + " is supported = " + supported); return supported; }
private Importer createImporter(final InputFile file, final SpecificationListBuilder builder) { final ImporterFactory importerFactory = this.factoryLoader.getImporterFactory(file); final Importer importer = importerFactory.createImporter(file, builder); LOG.fine(() -> "Created importer of type '" + importer.getClass().getSimpleName() + "' for file '" + file + "'"); return importer; } }
/** * Finds a matching {@link ImporterFactory} that can handle the given * {@link Path}. If no or more than one {@link ImporterFactory} is found, * this throws an {@link ImporterException}. * * @param file * the file for which to get a {@link ImporterFactory}. * @return a matching {@link ImporterFactory} that can handle the given * {@link Path} * @throws ImporterException * when no or more than one {@link ImporterFactory} is found. */ public ImporterFactory getImporterFactory(final InputFile file) { final List<ImporterFactory> matchingImporters = getMatchingFactories(file); switch (matchingImporters.size()) { case 0: throw new ImporterException("Found no matching importer for file '" + file + "'"); case 1: return matchingImporters.get(0); default: throw new ImporterException( "Found more than one matching importer for file '" + file + "'"); } }
/** * Finds a matching {@link ImporterFactory} that can handle the given * {@link Path}. If no or more than one {@link ImporterFactory} is found, * this throws an {@link ImporterException}. * * @param file * the file for which to get a {@link ImporterFactory}. * @return a matching {@link ImporterFactory} that can handle the given * {@link Path} * @throws ImporterException * when no or more than one {@link ImporterFactory} is found. */ public ImporterFactory getImporterFactory(final InputFile file) { final List<ImporterFactory> matchingImporters = getMatchingFactories(file); switch (matchingImporters.size()) { case 0: throw new ImporterException("Found no matching importer for file '" + file + "'"); case 1: return matchingImporters.get(0); default: throw new ImporterException( "Found more than one matching importer for file '" + file + "'"); } }