use of org.opendaylight.yangtools.plugin.generator.api.FileGeneratorFactory in project yangtools by opendaylight.
the class YangToSourcesProcessor method instantiateGenerators.
private List<GeneratorTaskFactory> instantiateGenerators() throws MojoExecutionException, MojoFailureException {
final List<GeneratorTaskFactory> generators = new ArrayList<>(codeGeneratorArgs.size());
for (CodeGeneratorArg arg : codeGeneratorArgs) {
generators.add(CodeGeneratorTaskFactory.create(arg));
LOG.info("{} Code generator instantiated from {}", LOG_PREFIX, arg.getCodeGeneratorClass());
}
// Search for available FileGenerator implementations
final Map<String, FileGeneratorFactory> factories = Maps.uniqueIndex(ServiceLoader.load(FileGeneratorFactory.class), FileGeneratorFactory::getIdentifier);
// Assign instantiate FileGenerators with appropriate configurate
for (Entry<String, FileGeneratorFactory> entry : factories.entrySet()) {
final String id = entry.getKey();
FileGeneratorArg arg = fileGeneratorArgs.get(id);
if (arg == null) {
LOG.debug("{} No configuration for {}, using empty", LOG_PREFIX, id);
arg = new FileGeneratorArg(id);
}
try {
generators.add(FileGeneratorTaskFactory.of(entry.getValue(), arg));
} catch (FileGeneratorException e) {
throw new MojoExecutionException("File generator " + id + " failed", e);
}
LOG.info("{} Code generator {} instantiated", LOG_PREFIX, id);
}
return generators;
}
Aggregations